Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build Failure in Jenkins, Found duplicate resources

I recently added this dependency to pom.xml

<dependency>
    <groupId>com.jayway.restassured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>2.4.0</version>
</dependency>

My builds are failing in jenkins with the following error message:

[WARNING] Found duplicate resources in [org.codehaus.groovy:groovy:2.3.7,org.codehaus.groovy:groovy-json:2.3.7,org.codehaus.groovy:groovy-xml:2.3.7] :
[WARNING]   META-INF/groovy-release-info.properties
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5:37.485s
[INFO] Finished at: Mon Mar 09 10:10:49 PDT 2015
[INFO] Final Memory: 46M/381M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving disabled
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.4:check (default) on project LightmileTest: Found duplicate classes/resources -> [Help 1]
like image 984
user3443193 Avatar asked Mar 09 '15 18:03

user3443193


2 Answers

Background/Details

I had a similar issue and this threw me for a loop for a while and I started to question my maven knowledge and did some digging. If you want to learn more about duplicate finder, you can read the readme on their github: https://github.com/ning/maven-duplicate-finder-plugin

For the project I was on, I determined I could do excludes in the dependencies or add exceptions to the duplicate finder. I saw both in my project and wondered when it was appropriate to do which.

The message from the plugin helps identify where duplication resides. You'll normally see this when you try to add new dependencies. When you see that, there are two options, either exclude things from the dependencies, or create exceptions in your com.ning.maven.plugins:duplicate-finder-maven-plugin configuration.

Summary / Conclusion

Adding an exception, just ignores the problem. So the cleaner way is add the excludes in the dependencies. This way you get exactly what you expect/desire. Furthermore, going down the exception route would just add a ton of extra work that isn't really useful. So the intent of the plugin is to help you identify duplications, then try to handle them via excludes in the dependencies.

Example of How to Do Exclude

In your example/case, one of the following should work for you:

<dependency>
    <groupId>com.jayway.restassured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>2.4.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-json</artifactId>
        </exclusion>
    </exclusions>
</dependency>

or

<dependency>
    <groupId>com.jayway.restassured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>2.4.0</version>
    <exclusions>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
        </exclusion>
    </exclusions>
</dependency>
like image 169
James Oravec Avatar answered Oct 28 '22 20:10

James Oravec


It is likely that your new dependency is failing on this test your are doing via Maven (duplicate-finder-plugin). Run the manual check from command line (on the level of the POM file) to find out what are the offending classes:

mvn com.ning.maven.plugins:duplicate-finder-maven-plugin:1.0.4:check

Then you can either remove the dependency or configure the Maven plugin to ignore these. (config here)

like image 23
Gergely Bacso Avatar answered Oct 28 '22 18:10

Gergely Bacso