8

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]
user3443193
  • 113
  • 1
  • 1
  • 4

5 Answers5

4

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>
James Oravec
  • 19,579
  • 27
  • 94
  • 160
2

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)

Gergely Bacso
  • 14,243
  • 2
  • 44
  • 64
  • I am not using the duplicate-finder plugin in my pom. But I still get build failure because of that? – user3443193 Apr 06 '15 at 23:30
  • The last line of your console shows that this duplicate finder plugin is running and causing your build to fail. If you are not using this intentionally, then remove it and see if it works. – Gergely Bacso Apr 07 '15 at 05:51
0

dependency:analyze-duplicate Analyzes the and tags in the pom.xml and determines the duplicate declared dependencies.

  mvn dependency:analyze-duplicate
-1

What you can do is to follow the rule of scope, meaning that, separate dependencies according to their scopes, such as in your case, rest assured used for testing, why not to put it under the scope of a test:

<scope>test</scope>

Secondary, what I usually do is executing exactly same commands from Jenkins on my local machine and usually it does help, from you error log I think it is not rest assured related, so please try to run MVN goal which is on Jenkins side locally and make sure you have the same error. If not, it can be a different configuration of maven for example via settings.xml in Jenkins machine.

BigGinDaHouse
  • 1,282
  • 9
  • 19
-2

Use to avoid the duplicate finder.

krishna Ram
  • 639
  • 3
  • 9
  • 20