You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by James Adams <mo...@gmail.com> on 2009/06/09 23:00:32 UTC

Duplicate class warnings when using shade plugin

I am building my JAR file using the shade plugin in order to give me an
all-in-one JAR artifact which contains all dependency JARs.  When I build
using "mvn clean install" I always get thousands of message like the
following, indicating that there's a duplicate class file in a JAR in the
repository, which I assume is coming from the shade plugin when it's doing
its thing:

[WARNING] We have a duplicate
net/sf/cglib/util/StringSwitcher$StringSwitcherKey.class in
C:\dev\maven\repository\cglib\cglib-full\2.0.2\cglib-full-2.0.2.jar

Is this something I should worry about or is it just an annoyance to live
with for now?  The resulting JAR artifact works well, maybe this is nothing
to worry over, but I want to ask here in case there is something I can fix
which will make these warning messages go away.  I can't find anything about
this using Google, etc.

Here's the plugin section from my pom.xml:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>junit:junit</exclude>
                                </excludes>
                            </artifactSet>
                            <transformers>
                                <transformer
                                   
implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"
/>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


Thanks in advance for any advice.

--James
-- 
View this message in context: http://www.nabble.com/Duplicate-class-warnings-when-using-shade-plugin-tp23951216p23951216.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Duplicate class warnings when using shade plugin

Posted by Dominic Mitchell <do...@semantico.com>.
On 9 Jun 2009, at 22:00, James Adams wrote:
> I am building my JAR file using the shade plugin in order to give me  
> an
> all-in-one JAR artifact which contains all dependency JARs.  When I  
> build
> using "mvn clean install" I always get thousands of message like the
> following, indicating that there's a duplicate class file in a JAR  
> in the
> repository, which I assume is coming from the shade plugin when it's  
> doing
> its thing:
>
> [WARNING] We have a duplicate
> net/sf/cglib/util/StringSwitcher$StringSwitcherKey.class in
> C:\dev\maven\repository\cglib\cglib-full\2.0.2\cglib-full-2.0.2.jar
>
> Is this something I should worry about or is it just an annoyance to  
> live
> with for now?  The resulting JAR artifact works well, maybe this is  
> nothing
> to worry over, but I want to ask here in case there is something I  
> can fix
> which will make these warning messages go away.  I can't find  
> anything about
> this using Google, etc.

I ran into this with different variations of commons-logging. There's  
commons-logging (the full jar) and commons-logging-api (JDK14 logging  
only).  But they contain some of the same classes even though they're  
different artifacts.  Different dependencies were pulling in different  
versions of the same class.

In this case, I used a dependencyManagement section to exclude commons- 
logging-api.  But this isn't a general solution.  You might not be  
able to exclude the jar that contains duplicates.

That said, the warnings are ignorable.

-Dom

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org