Code getting older references only locally - java

So, I am currently working on a project that uses Maven.
I added a spring-context dependency, on the latest version, and made sure to exclude any older spring references from other dependencies.
Seems like the code is getting an older reference still (even though it does not have a source attached anymore due to the old version of spring being excluded).
This issue is happening only on my local machine, as other people from the project downloaded the exact same code and didn't get this strage bean reference error.
Here's the pom.xml (I've erased internal project names)
I have tried running mvn clean install, checking dependencies with dependency:tree and nothing solves this problem.
<?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>---</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Project</name>
-<build>
<sourceDirectory>src</sourceDirectory>
-<plugins>
-<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
-<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
-<dependencies>
<!-- dependencies -->
-<dependency>
<groupId>---</groupId>
<artifactId>model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
-<dependency>
<groupId>---</groupId>
<artifactId>general.dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
-<dependency>
<groupId>---</groupId>
<artifactId>ExternalJavaConfig</artifactId>
<version>1.0.9-RELEASE</version>
-<exclusions>
-<exclusion>
groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
-<dependency>
<groupId>---</groupId>
<artifactId>db</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
-<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
-<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
-<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
-<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
-<dependency>
<groupId>---</groupId>
<artifactId>---</artifactId>
<version>0.0.3-SNAPSHOT</version>
</dependency>
<!-- External dependencies -->
-<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
</dependency>
-<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
-<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
-<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.2.7.RELEASE</version>
</dependency>
-<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.2.7.RELEASE</version>
</dependency>
-<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.1</version>
</dependency>
-<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.1</version>
</dependency>
<!-- External dependencies in internal repo-->
-<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc4</artifactId>
<version>11.1.0.0</version>
</dependency>
-<dependency>
<groupId>---</groupId>
<artifactId>---</artifactId>
<version>5.0.0.34</version>
</dependency>
-<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-instrument</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
-<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
</dependencies>
</project>```

If the problem only appears on your computer, delete the local repository (usually in your user directory under .m2/repository) and try again.

Somehow the code has been conflicting with other dependencies. After I have downloaded only those specific ones, it stopped conflicting.

Related

What is causing java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z

Looking around at similar posts for this error, it seems that the issue comes from having incompatible versions of the same dependency. I have one project that calls a class from another, thus I have two separate pom.xml's, but both have the same version of the jackson dependency so I'm not sure what is causing this error. Here are my two pom.xml's:
pom.xml #1
<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>com.microsoft.bingads</groupId>
<version>12.13.3</version>
<name>Bing Ads Java SDK</name>
<description>The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.</description>
<url>https://github.com/BingAds/BingAds-Java-SDK</url>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.googlecode.jcsv</groupId>
<artifactId>jcsv</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${http.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.bingads</groupId>
<artifactId>microsoft.bingads</artifactId>
<version>12.13.3</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf.version>3.3.2</cxf.version>
<http.version>4.5.3</http.version>
</properties>
<artifactId>microsoft.bingads</artifactId>
</project>
and pom.xml #2
<?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>com.google.api-ads.examples</groupId>
<artifactId>adwords-axis-examples</artifactId>
<version>4.6.0</version>
<packaging>jar</packaging>
<name>AdWords Examples using Axis</name>
<description>
This project contains examples of using the Ads APIs client library for Java
with AdWords and the Apache Axis framework. Please see the README file for
more information about how to use the library.
</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<smokeMainClass>adwords.axis.v201809.basicoperations.GetCampaigns</smokeMainClass>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<!-- Ads client library dependencies -->
<dependency>
<groupId>com.google.api-ads</groupId>
<artifactId>ads-lib</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>com.google.api-ads</groupId>
<artifactId>adwords-axis</artifactId>
<version>4.6.0</version>
</dependency>
<!-- Third party dependencies -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --><!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<!-- Configuration to use log4j for logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>smoketest</id>
<properties>
<exec.mainClass>${smokeMainClass}</exec.mainClass>
</properties>
</profile>
</profiles>
</project>
When running each class separately, they both compile and run as intended, but when I call b.foo() from class a, I get the error in the title. Any ideas what is happening?
I poked around deeper through some of the dependencies and found that one was using a lower version of Jackson that you couldn't see on the surface. So if you have this problem and you're using Eclipse, view your pom.XML through the Dependencies Hierarchy view and you should be able to see where the incompatibility comes from.
You can maintain the parent module and other child modules integration using maven, and add the dependency in parent module so that should be consider by both child module.

Maven: testCompile failed multiple points

My project has the following pom.xml:
<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>org.dummy</groupId>
<artifactId>oauth-test</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>oauth-test Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scribe.version>2.5.2</scribe.version>
<spring.version>4.3.6.RELEASE</spring.version>
<spring-test.version>4.3.6.RELEASE</spring-test.version>
<spring-security.version>4.2.1.RELEASE</spring-security.version>
<slf4j.version>1.7.7</slf4j.version>
<retrofit.version>2.1.0</retrofit.version>
<okhttp.version>3.4.1</okhttp.version>
<kripton.version>3.1.0</kripton.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- JSP Library -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- scribe -->
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-apis</artifactId>
<version>${scribe.version}</version>
</dependency>
<!-- Spring and Transactions -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.7</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.7</version>
</dependency>
<!-- Spring ORM support -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Kripton -->
<dependency>
<groupId>com.abubusoft</groupId>
<artifactId>kripton</artifactId>
<version>${kripton.version}</version>
</dependency>
<!-- slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>${retrofit.version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.abubusoft</groupId>
<artifactId>kripton-retrofit-converter</artifactId>
<version>${kripton.version}</version>
</dependency>
</dependencies>
<build>
<finalName>oauth-test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>com.abubusoft</groupId>
<artifactId>kripton-processor</artifactId>
<version>${kripton.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Now.. i run command:
mvn install
And i receive the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile (default-testCompile) on project oauth-test: Execution default-testCompile of goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile failed: multiple points -> [Help 1]
What is wrong?
Finally i found the problem. In the compile plugin, i used ${java.version} to define source level and target level, but i didn't define this placeholder. Just define in properties section
<java.version>1.8</java.version>
And everything works.

jersey-spring jar is compilation issue

I want to create a maven jersey spring integrated project. When I am trying to add
com.sun.jersey.contribs:jersey-spring:jar:1.9.1
jar my project is not compiling, without this jar, its working fine.
Here is my pom.xml
<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.jwt.rest</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>RESTfullApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.17</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.9.1</version>
</dependency>
</dependencies>
<build>
<finalName>myapp</finalName>
</build>
</project>
Stacktrace
[WARNING] POM for 'com.sun.jersey:jersey-server:pom:1.9.1:compile' is invalid.
Its dependencies (if any) will NOT be available to the current build.
[ERROR] An error occurred during dependency resolution of the following artifact:
org.springframework:spring-core:null
Caused by: Unable to get dependency information: Unable to read local copy of metadata: Cannot read metadata from '/home/innoeye/repo2/org/springframework/spring-core/maven-metadata-glassfish-repository.xml': end tag name </body> must match start tag name <hr> from line 5 (position: TEXT seen ...</center>\r\n</body>... #6:8)
org.springframework:spring-core:jar:null
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
m2.java.net (http://download.java.net/maven/2),
jvnet-nexus-snapshots (https://maven.java.net/content/repositories/snapshots),
glassfish-repository (http://maven.glassfish.org/content/groups/glassfish),
repository.jboss.org (http://repository.jboss.org/nexus/content/groups/public/)
Path to dependency:
1) com.jwt.rest:myapp:war:1.0-SNAPSHOT
2) com.sun.jersey.contribs:jersey-spring:jar:1.9.1

Maven project setup

I currently got a project with flat structure with following dependency;
Core --> core.jar
Service --> WAR
Domain --> domain.jar
Web -> WAR
Pretty much, everything depends on core.jar from Core module, and Web depend on domain jar from Domain module, which is depend on Core.
I'm planning to convert this to Maven, I need some feed back on possible best structure I should use.
Choices I have is to keep the current structure then produce jar files from each module and use them as part of dependency with maven. Or
Re structure the modules in some sort of hierarchy, where I need some help.
I want to follow some sort of best practice use of Maven.
Set up a parent pom, which you can use to keep the dependencies managed across the child projects. Then set up each of your jar/war artifacts as modules.
Each module sources its dependencies using the normal <dependencies> in the module pom.
so have this:
parent-project [pom]:
modules:
core [jar]
domain [jar] - depends on core
service [war] - depends on core
web [war] - depends on domain
And as a concrete example, here's a sample of one of my projects:
parent pom
<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>org.example</groupId>
<artifactId>myproject-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>myproject-parent</name>
<url>http://maven.apache.org</url>
<properties>
<jersey.version>2.6</jersey.version>
<jsonunit.version>1.5.5</jsonunit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.1.4.RELEASE</spring.version>
</properties>
<modules>
<module>api-client</module>
<module>load-tests</module>
<module>regression-tests</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
</reporting>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>2.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.0.5-beta</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.22</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit</artifactId>
<version>${jsonunit.version}</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit-fluent</artifactId>
<version>${jsonunit.version}</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
</dependencyManagement>
api-client
<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>
<artifactId>api-client</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.example</groupId>
<artifactId>myproject-parent</artifactId>
<version>1.0.0</version>
</parent>
<properties>
<xmlunit.version>2.0.0-alpha-03</xmlunit.version>
</properties>
<name>api-client</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<version>${xmlunit.version}</version>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
<version>${xmlunit.version}</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.json-unit</groupId>
<artifactId>json-unit-fluent</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
... snip ...
</plugins>
</build>
</project>
and finally load-tests, which depends on api-client
<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>
<artifactId>load-tests</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>org.example</groupId>
<artifactId>myproject-parent</artifactId>
<version>1.0.0</version>
</parent>
<name>load-tests</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>api-client</artifactId>
<version>${parent.version}</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<plugins>
... snip ...
</plugins>
</build>
</project>
I think what I m trying to demonstrate will match your choice.
Create a POM Project as Parent
Add each jar and war as Module
Choices I have is to keep the current structure then produce jar files from each module and use them as part of dependency with maven.

Exclude Test Classes in dependend Maven JAR

We have an EAR Project which assembles a WAR File and has some JAR Files as dependency. POM.xml of the EAR looks like this:
<dependencies>
<dependency>
<groupId>our.package</groupId>
<artifactId>package-impl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${maven.ear.plugin.version}</version>
<configuration>
<version>5</version>
<generateApplicationXml>false</generateApplicationXml>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>de.project</groupId>
<artifactId>project.war</artifactId>
<bundleDir>/</bundleDir>
<bundleFileName>project.war</bundleFileName>
<contextRoot>project</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
The package-impl, which is included in the EAR as JAR, has some Test Classes in it. Unfortunatly these Test Classes are bundled whith the JAR, when the EAR is assembled. Besides the facet, that Maven should inlucde the test classe, how can I exclude these Test classes in the JAR, when the EAR is assembled?
All Test Classes in package-impl are in src/test/java Source Folder.
Regards
Sven
UPDATE:
When I build the package-impl indepent from tha EAR manually the test classes are not included (as expected).
UPDATE2
Here is the complete package-impl POM.xml
<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>
<artifactId>project-impl</artifactId>
<parent>
<groupId>de.company</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../project</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>${jee6.version}</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>${hibernate.jpa-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<version>${jboss-vfs.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons-lang.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf-api.version}</version>
<scope>provided</scope>
</dependency>
<!-- depenencies on third party modules -->
<dependency>
<groupId>org.jboss.solder</groupId>
<artifactId>solder-impl</artifactId>
<version>${jboss.solder.solder-impl.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
<version>${org.jboss.seam-persistence.version}</version>
<exclusions>
<!-- already provided by jboss as -->
<exclusion>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
<version>${jboss.richfaces.version}</version>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
<version>${jboss.richfaces.version}</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${org.reflections.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.0.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.0.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>1.1.5.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
UPDATE3
This ended up to be an eclipse setting. The EAR-Project had a list of folders which contained the test folder.
The problem has to be in the module for the dependent JAR file. A perhaps someone has configured the build to include the test classes in the JAR. If so, you should fix the module (i.e. its POM file) to not do this, rather than trying to deal with it in your EAR module.
In the past I have accidentally put Test classes in src/main/java instead of src/test/java, and this works(compiles, runs) in eclipse but fails my build because JUnit is not in the class path for the build.
May or may not be true in your case but worth checking.

Categories