Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid the "Overlappping classes" warning in a maven build?

I have a module which have dependency on other two projects but I am getting this when building projects with.

Although no error is coming, but I am getting lots of warning for overlapping the same class:

[WARNING] commons-logging-1.2.jar, jcl-over-slf4j-1.7.12.jar define 6 overlappping classes: 
[WARNING]   - org.apache.commons.logging.impl.SimpleLog$1
[WARNING]   - org.apache.commons.logging.Log
[WARNING]   - org.apache.commons.logging.impl.SimpleLog
[WARNING]   - org.apache.commons.logging.LogConfigurationException
[WARNING]   - org.apache.commons.logging.impl.NoOpLog
[WARNING]   - org.apache.commons.logging.LogFactory
[WARNING] aspectjrt-1.7.0.jar, aspectjweaver-1.8.6.jar define 128 overlappping classes: 
[WARNING]   - org.aspectj.internal.lang.reflect.SignaturePatternImpl
[WARNING]   - org.aspectj.runtime.reflect.SignatureImpl
[WARNING]   - org.aspectj.internal.lang.reflect.DeclareSoftImpl
[WARNING]   - org.aspectj.lang.reflect.AjType
[WARNING]   - org.aspectj.lang.JoinPoint$StaticPart
[WARNING]   - org.aspectj.runtime.internal.cflowstack.ThreadStackImpl11
[WARNING]   - org.aspectj.runtime.internal.cflowstack.ThreadStack
[WARNING]   - org.aspectj.internal.lang.reflect.InterTypeDeclarationImpl
[WARNING]   - org.aspectj.internal.lang.reflect.DeclareAnnotationImpl
[WARNING]   - org.aspectj.lang.annotation.SuppressAjWarnings
[WARNING]   - 118 more...
[WARNING] maven-shade-plugin has detected that some .class files
[WARNING] are present in two or more JARs. When this happens, only
[WARNING] one single version of the class is copied in the uberjar.
[WARNING] Usually this is not harmful and you can skeep these
[WARNING] warnings, otherwise try to manually exclude artifacts
[WARNING] based on mvn dependency:tree -Ddetail=true and the above
[WARNING] output
[WARNING] See http://docs.codehaus.org/display/MAVENUSER/Shade+Plugin
[INFO] Replacing original artifact with shaded artifact.

How can I avoid those warnings?

like image 403
Anuj Vishwakarma Avatar asked Oct 18 '22 11:10

Anuj Vishwakarma


1 Answers

Use the Maven plugin Dependency Tree, and do so with

mvn clean dependency:tree
# or (mvn 3)
mvn clean org.apache.maven.plugins:maven-dependency-plugin:3.0.1:tree

The clean is important to avoid any side-effect of old target content.

Then, depending on the plugin you are using, you can add exclusion rules as in this answer, in order to avoid those error message.

As seen in MRUNIT-209, the 2.5.1 version of dependency-tree does not run with Maven 3.x.x.
Using the full name org.apache.maven.plugins:maven-dependency-plugin:3.0.1:tree will force the use of the 3.0.1 version of the maven-dependency-plugin.

like image 96
VonC Avatar answered Oct 21 '22 07:10

VonC