I just recently created my own nexus repository manager, and when I went to add it to my own project's settings.xml file, now none of my dependencies are resolving. Here is my POM.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>projectname</groupId>
<artifactId>projectname</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>projectname</name>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<snapshotRepository>
<id>maven-snapshots</id>
<url>https://nexus.repo.placeholder/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>nexus-releases</id>
<url>https://nexus.repo.placeholder/repository/maven-releases/</url>
</repository>
</distributionManagement>
<build>
<finalName>projectname</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>fr.minuskube.inv</groupId>
<artifactId>smart-invs</artifactId>
<version>1.2.7</version>
</dependency>
<dependency>
<groupId>de.themoep</groupId>
<artifactId>inventorygui</artifactId>
<!--The following version may not be the latest. Check it before using.-->
<version>1.4.2-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.1</version>
</dependency>
</dependencies>
</project>
However, no longer are my dependencies resolving in my pom anymore.
settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://repo.template/repository/maven-public/</url>
</mirror>
</mirrors>
<localRepository>${user.home}/.m2/repository</localRepository>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://maven.apache.org</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://maven.apache.org</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<servers>
<server>
<id>maven-releases</id>
<username>username</username>
<password>password</password>
</server>
<server>
<id>maven-snapshots</id>
<username>username</username>
<password>password</password>
</server>
</servers>
</settings>
All of my credentials are correct to connect to the Nexus system and such as well. Could it be because I have defined a new settings.xml? Do I need to put something in it to fetch the proper repositories for other dependencies as well?
Related
After upgrading the Spring parent POM application from 1.2.8.RELEASE to 1.3.8.RELEASE I noticed that properties defined in settings.xml could not be read. Does spring does not support reading from settings.xml in versions higher than 1.2.8.RELEASE.
Code is available on GIT at : https://github.com/Ravivyas1989/demo
Here is the example of code snippet for my problem POM.xml:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<repositories>
<repository>
<id>spring-release</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>atlassian-public</id>
<url>https://maven.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
<repository>
<id>jr-ce-snapshots</id>
<name>JasperReports CE Snapshots</name>
<url>http://jaspersoft.jfrog.io/jaspersoft/jr-ce-snapshots</url>
</repository>
<repository>
<id>redshift</id>
<url>http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release</url>
</repository>
<repository>
<id>project-repo</id>
<url>file:${project.basedir}/src/main/resources/repo/</url>
</repository>
<repository>
<id>jcenter-release</id>
<name>jcenter</name>
<url>http://jasperreports.sourceforge.net/maven2/</url>
</repository>
<!-- bouncy-gpg Bouncy Castle with GPG -->
<repository>
<id>bintray</id>
<name>bintray</name>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>api</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<!-- Always download and attach dependencies source code -->
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<!-- To create project run: mvn eclipse:eclipse -->
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Duser.timezone=US/Eastern ${argLine}</argLine>
<!--<systemProperties>
<property>
<name>createJsonFiles</name>
<value>${createJsonFiles}</value>
</property>
</systemProperties>-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
<forkCount>1</forkCount>
<argLine>-Duser.timezone=US/Eastern</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<excludes>
<exclude>
**/reporting-functions/**
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/reportTemplates</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/~$*.xlsx</exclude>
</excludes>
</resource>
</resources>
</build>
Here is DemoApplication.java
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Here is settings.xml:
<settings>
<servers>
<server>
<id>snapshots</id>
<username>${NEXUS_USERNAME}</username>
<password>${NEXUS_PASSWORD}</password>
</server>
<server>
<id>releases</id>
<username>${NEXUS_USERNAME}</username>
<password>${NEXUS_PASSWORD}</password>
</server>
<server>
<id>configs</id>
<username>${NEXUS_USERNAME}</username>
<password>${NEXUS_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>d02</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- General Database Properties -->
<db.userName>appservers</db.userName>
<db.password>appservers</db.password>
</properties>
</profile>
</profiles>
Testcontroller.java
package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class TestController {
#Autowired
private Environment env;
#RequestMapping(method = RequestMethod.GET, value = "${db.user}")
public String testing1() {
System.out.println("db.user is "+env.getProperty("db.user"));
return "hostName";
}
}
application.properties
db.user=${db.userName}
platform=testlab
server.port=9090
"Notice the #property# instead of ${property}. in the application.properties file.
The spring-boot-starter-parent pom redefines the standard ${} delimiter as #:"
My question is answered here:
Cannot get maven project.version property in a Spring application with #Value
Maven always reads the properties from the settings.xml. There must be some other error.
I'm just learning Kotlin and I can't install library Klaxon on my Maven project.
GitHub: https://github.com/cbeust/klaxon
I copy settings from https://bintray.com/cbeust/maven/klaxon to my pom.xml, but it doesn't work.
I try to copy and paste this to pom.xml:
<!-- https://mvnrepository.com/artifact/com.beust/klaxon -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>klaxon</artifactId>
<version>4.0.2</version>
</dependency>
But it doesn't work.
Could somebody help me to install this library? Or just give me a link to find out learn how to install any library to my Maven project?
I can't find this information, maybe I can't write correct a google search.
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FORMS</groupId>
<artifactId>FORMS</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Stemmer Stemmer</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.version>1.3.21</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<junit.version>4.12</junit.version>
</properties>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-cbeust-maven</id>
<name>bintray</name>
<url>https://dl.bintray.com/cbeust/maven</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-cbeust-maven</id>
<name>bintray-plugins</name>
<url>https://dl.bintray.com/cbeust/maven</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.beust/klaxon -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>klaxon</artifactId>
<version>5.0.5</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Dependencies must be inside the <dependencies> tag. Look up the structure of a Maven POM to learn more.
https://maven.apache.org/pom.html
Thanks for your help! My comrades helped me: I had to sign in for bintray.com and clicked to set me up and download settings.xml to my project in catalog with pom.xml because of politics of bintray.com
I was trying to run this pom.xml using the maven commands in my Jenkins docker container in my local. The build fails every time and returns me this error
Failed to execute goal
com.mulesoft.munit.tools:munit-maven-plugin:2.1.4:test (test) on
project ms3-sample-api: Build Fail: Error: Could not find or load main
class org.mule.munit.remote.RemoteRunner
And if I skip the tests the build is successful and this code even works in my remote but not on my local. Any suggestions and concerns on this. Thanks in advance
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>ms3-sample-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>
<name>ms3-sample-api</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<app.runtime>4.1.4</app.runtime>
<mule.maven.plugin.version>3.1.6</mule.maven.plugin.version>
<munit.version>2.1.4</munit.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<classifier>mule-application</classifier>
</configuration>
</plugin>
<plugin>
<groupId>com.mulesoft.munit.tools</groupId>
<artifactId>munit-maven-plugin</artifactId>
<version>${munit.version}</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
<goal>coverage-report</goal>
</goals>
</execution>
</executions>
<configuration>
<coverage>
<runCoverage>true</runCoverage>
<requiredApplicationCoverage>0</requiredApplicationCoverage>
<requiredResourceCoverage>0</requiredResourceCoverage>
<requiredFlowCoverage>0</requiredFlowCoverage>
<formats>
<format>html</format>
<format>console</format>
<format>json</format>
</formats>
</coverage>
</configuration>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>src/test/munit</directory>
</testResource>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/main/mule</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.3.2</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.1.2</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-apikit-module</artifactId>
<version>1.1.9</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-runner</artifactId>
<version>2.1.4</version>
<classifier>mule-plugin</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-tools</artifactId>
<version>2.1.4</version>
<classifier>mule-plugin</classifier>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>anypoint-exchange</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v1/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
This can be resolved when we look into the container we need to install java manually and set their paths in jenkins->config tools. It worked fine for me
Has anyone been successful for using Maven and Scalatra 2.2.1?
I found this old archetype https://github.com/Srirangan/scalatra-maven-prototype and tried to update the dependency versions, but I keep hitting incompatibility issues.
I'd like to use:
Scalatra 2.2.1
Scala 2.10
I think that Jetty has some problems to run the produced war.
I would highly appreciate your help on this one.
Here's the example project which I am using:
http://www.scalatra.org/2.2/getting-started/first-project.html
And my current pom.xml:
<?xml version='1.0' encoding='UTF-8'?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-scalatra-web-app</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<scalatra.version>2.2.1</scalatra.version>
</properties>
<build>
<finalName>scalatra-maven-prototype</finalName>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.17</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra_2.10</artifactId>
<version>${scalatra.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-scalate_2.10</artifactId>
<version>${scalatra.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-specs2_2.10</artifactId>
<version>${scalatra.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0.20100224</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>SonatypeNexusSnapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>FuseSourceSnapshotRepository</id>
<name>FuseSource Snapshot Repository</name>
<url>http://repo.fusesource.com/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>ScalaToolsMaven2Repository</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
</project>
Ok after a lot of crying, I found the correct versions to use, and the correct artifacts.
Hope that it'll be helpful for someone:
<?xml version='1.0' encoding='UTF-8'?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-scalatra-web-app</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<scalatra.version>2.2.1</scalatra.version>
</properties>
<build>
<finalName>scalatra-maven-prototype</finalName>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.4.v20130625</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra_2.10</artifactId>
<version>${scalatra.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-scalate_2.10</artifactId>
<version>${scalatra.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scalatra</groupId>
<artifactId>scalatra-specs2_2.10</artifactId>
<version>${scalatra.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.0.4.v20130625</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>SonatypeNexusSnapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>FuseSourceSnapshotRepository</id>
<name>FuseSource Snapshot Repository</name>
<url>http://repo.fusesource.com/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>ScalaToolsMaven2Repository</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
</project>
In our multiple module maven (3) project we are utilising the maven checkstyle plugin. It looks like that since we've shifted the guava dependency to our parent pom, we can't execute successfully the checkstyle:checkstyle goal anymore, because it fails with the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-
plugin:2.10:checkstyle (default-cli) on project init: Execution default-cli of goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.10:checkstyle failed: An API
incompatibility was encountered while executing org.apache.maven.plugins:maven-
checkstyle-plugin:2.10:checkstyle: java.lang.NoSuchMethodError:
com.google.common.collect.ImmutableSortedSet.of([Ljava/lang/Comparable;)Lcom/google
/common/collect/ImmutableSortedSet;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-checkstyle-plugin:2.10
The reason might be that the maven checkstyle plugin depends on the checkstyle framework, which depends on the google-collections framework (that is nowadays included in the google guava framework), i.e., that checkstyle calls a method that is not part of google collections in guava anymore.
Here is an excerpt of the parent pom that were are utilising:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ourcompany.ourproject</groupId>
<artifactId>ourproject</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>our project</name>
<modules>
<module>init</module>
...
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.11</junit.version>
<maven-compiler-plugin.version>3.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.14</maven-surefire-plugin.version>
<maven-checkstyle-plugin.version>2.10</maven-checkstyle-plugin.version>
<maven-pmd-plugin.version>3.0.1</maven-pmd-plugin.version>
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
<java.source.version>1.6</java.source.version>
<java.target.version>1.6</java.target.version>
<google.guava.version>14.0.1</google.guava.version>
</properties>
<repositories>
<repository>
<id>nexus</id>
<name>Internal Maven Repository</name>
<url>http://ourinternalmavenrepository/nexus/content/groups/public</url>
</repository>
...
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<configuration>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
<distributionManagement>
<repository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://ourinternalmavenrepository/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://ourinternalmavenrepository/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<profiles>
...
<profile>
<id>metrics</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<!-- CHECKSTYLE -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>our_checkstyle.xml</configLocation>
<failsOnError>false</failsOnError>
<consoleOutput>true</consoleOutput>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
</configuration>
<dependencies>
<dependency>
<groupId>com.ourcompany.ourproject</groupId>
<artifactId>init</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<failsOnError>false</failsOnError>
<source>${java.source.version}</source>
<target>${java.source.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>our_checkstyle.xml</configLocation>
<targetJdk>${java.source.version}</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${maven-pmd-plugin.version}</version>
<configuration>
<targetJdk>${java.source.version}</targetJdk>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
<!-- <dependencyManagement> -->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
...
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${google.guava.version}</version>
</dependency>
...
</dependencies>
<!-- </dependencyManagement> -->
I think that utilising the maven checkstyle plugin in a maven project is very common as well as utilising the guava framework. So I'm really wondering what we are doing wrong here ;)
Thanks a lot #AndrewLogvinov. He prodivded the working solution in his comment to this question. One just needs to add the google-collections dependency to the dependencies of the maven-checkstyle-plugin:
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>1.0</version>
</dependency>