Search code examples
mavenear

Excluding some 3rd party jar in ear using maven


I am building an ear using maven <packaging>ear</packaging> tag. One of the declared dependencies is adding it's transitive dependency to the generated ear. Is there any way to exclude this in the generated ear?

That is, my EAR pom has a dependency on module_A, this somewhere along the tree has a dependency on module_X which is getting packaged in the generated ear.

Is there any way not to include this(module_X) in the ear?

Directly adding an excludes tag for module_X in my pom did not work.


Solution

  • Everything is possible with maven. You just have to simly add a tag exclusions in the pom of your ear, something like that :

    <dependency>
       <groupId>my.group</groupId>
       <artifactId>module_A</artifactId>
       <exclusions>
          <exclusion>
             <groupId>my.group</groupId>
             <artifactId>module_X</artifactId>
          </exclusion>
       </exclusions>
    </dependency>