title: Excluding transitive dependency more than one level
body: <p>I have this pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;gs-maven&lt;/artifactId&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
      &lt;version&gt;0.1.0&lt;/version&gt;
  
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;phase&gt;package&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;shade&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;transformers&gt;
                                  &lt;transformer
                                      implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"&gt;
                                      &lt;mainClass&gt;hello.HelloWorld&lt;/mainClass&gt;
                                  &lt;/transformer&gt;
                              &lt;/transformers&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
                  &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
                  &lt;version&gt;4.1.4.Final&lt;/version&gt;
                  &lt;exclusions&gt;
                      &lt;exclusion&gt;
                          &lt;groupId&gt;javassist&lt;/groupId&gt;
                          &lt;artifactId&gt;javassist&lt;/artifactId&gt;
                      &lt;/exclusion&gt;
                  &lt;/exclusions&gt;
              &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;ch.simas.qlrm&lt;/groupId&gt;
              &lt;artifactId&gt;qlrm&lt;/artifactId&gt;
              &lt;version&gt;1.5.1&lt;/version&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
                      &lt;artifactId&gt;javax.persistence&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The dependency:tree is </p>
  
  <pre><code>[INFO] Scanning for projects...
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building gs-maven 0.1.0
  [INFO] ------------------------------------------------------------------------
  [INFO]
  [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ gs-maven ---
  [INFO] org.springframework:gs-maven:jar:0.1.0
  [INFO] +- org.hibernate:hibernate-core:jar:4.1.4.Final:compile
  [INFO] |  +- antlr:antlr:jar:2.7.7:compile
  [INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
  [INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
  [INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
  [INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
  [INFO] |  +- org.javassist:javassist:jar:3.15.0-GA:compile
  [INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
  [INFO] \- ch.simas.qlrm:qlrm:jar:1.5.1:compile
  [INFO]    +- org.eclipse.persistence:eclipselink:jar:2.5.1:compile
  [INFO]    |  +- org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
  [INFO]    |  \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
  [INFO]    \- com.h2database:h2:jar:1.3.170:compile
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.142 s
  [INFO] Finished at: 2015-01-23T15:43:19+05:30
  [INFO] Final Memory: 8M/81M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>Even though I have excluded javax.persistence I'm getting the following warnings while build</p>
  
  <pre><code>[WARNING] javax.persistence-2.1.0.jar, hibernate-jpa-2.0-api-1.0.1.Final.jar define 92 overlappping classes:
  [WARNING]   - javax.persistence.SecondaryTable
  [WARNING]   - javax.persistence.TableGenerator
  [WARNING]   - javax.persistence.NamedNativeQueries
  [WARNING]   - javax.persistence.TransactionRequiredException
  [WARNING]   - javax.persistence.SecondaryTables
  [WARNING]   - javax.persistence.JoinTable
  [WARNING]   - javax.persistence.Id
  [WARNING]   - javax.persistence.Embedded
  [WARNING]   - javax.persistence.EntityResult
  [WARNING]   - javax.persistence.EntityManager
  [WARNING]   - 82 more...
  [WARNING] javax.persistence-2.1.0.jar, eclipselink-2.5.1.jar define 24 overlappping classes:
  [WARNING]   - javax.persistence.NamedStoredProcedureQuery
  [WARNING]   - javax.persistence.ConstructorResult
  [WARNING]   - javax.persistence.ParameterMode
  [WARNING]   - javax.persistence.Index
  [WARNING]   - javax.persistence.AttributeConverter
  [WARNING]   - javax.persistence.NamedStoredProcedureQueries
  [WARNING]   - javax.persistence.Subgraph
  [WARNING]   - javax.persistence.ConstraintMode
  [WARNING]   - javax.persistence.Converts
  [WARNING]   - javax.persistence.criteria.CriteriaUpdate
  [WARNING]   - 14 more...
  [WARNING] javax.persistence-2.1.0.jar, eclipselink-2.5.1.jar, hibernate-jpa-2.0-api-1.0.1.Final.jar define 80 overlappping classes:
  [WARNING]   - javax.persistence.criteria.SetJoin
  [WARNING]   - javax.persistence.criteria.Predicate
  [WARNING]   - javax.persistence.CacheRetrieveMode
  [WARNING]   - javax.persistence.TupleElement
  [WARNING]   - javax.persistence.metamodel.PluralAttribute
  [WARNING]   - javax.persistence.AccessType
  [WARNING]   - javax.persistence.Access
  [WARNING]   - javax.persistence.metamodel.ManagedType
  [WARNING]   - javax.persistence.metamodel.ListAttribute
  [WARNING]   - javax.persistence.criteria.CriteriaBuilder$Trimspec
  [WARNING]   - 70 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.
  [INFO] Replacing /Users/sivakr/Documents/java/maven_1/target/gs-maven-0.1.0.jar with /Users/sivakr/Documents/java/maven_1/target/gs-maven-0.1.0-shaded.jar
  [INFO] Dependency-reduced POM written at: /Users/sivakr/Documents/java/maven_1/dependency-reduced-pom.xml
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 3.214 s
  [INFO] Finished at: 2015-01-23T15:43:11+05:30
  [INFO] Final Memory: 7M/81M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>How to exclude the duplicate jar's ? And eliminate warnings </p>
  
  <p><strong>UPDATED</strong> dependency:tree</p>
  
  <pre><code>[INFO] Scanning for projects...
  [INFO]
  [INFO] ------------------------------------------------------------------------
  [INFO] Building gs-maven 0.1.0
  [INFO] ------------------------------------------------------------------------
  [INFO]
  [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ gs-maven ---
  [INFO] org.springframework:gs-maven:jar:0.1.0
  [INFO] +- org.hibernate:hibernate-core:jar:4.1.4.Final:compile
  [INFO] |  +- antlr:antlr:jar:2.7.7:compile
  [INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
  [INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
  [INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
  [INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
  [INFO] |  +- org.javassist:javassist:jar:3.15.0-GA:compile
  [INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
  [INFO] \- ch.simas.qlrm:qlrm:jar:1.5.1:compile
  [INFO]    +- org.eclipse.persistence:eclipselink:jar:2.5.1:compile
  [INFO]    |  \- org.eclipse.persistence:commonj.sdo:jar:2.1.1:compile
  [INFO]    \- com.h2database:h2:jar:1.3.170:compile
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 1.138 s
  [INFO] Finished at: 2015-01-23T18:11:06+05:30
  [INFO] Final Memory: 8M/81M
  [INFO] ------------------------------------------------------------------------
  </code></pre>