cmn
cmn

Reputation: 383

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.

Upvotes: 0

Views: 174

Answers (2)

Zolt&#225;n
Zolt&#225;n

Reputation: 22156

If the dependency is scoped as compile in the parent POM and you need it to be provided within your EAR, you can use dependency management within the child POM where you need to change its scope:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.group</groupId>
            <artifactId>transitive-dependency</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Upvotes: 0

J&#233;rome Pieret
J&#233;rome Pieret

Reputation: 238

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>

Upvotes: 1

Related Questions