Is there anyway to exclude artifacts inherited from a parent POM?
Posted
by Miguel
on Stack Overflow
See other posts from Stack Overflow
or by Miguel
Published on 2010-04-21T09:40:37Z
Indexed on
2010/04/21
9:43 UTC
Read the original article
Hit count: 327
Artifacts from dependencies can be excluded by declaring an <exclusions>
element inside a <dependency>
But in this case it's needed to exclude an artifact inherited from a parent project. An excerpt of the POM under discussion follows:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>jruby</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<artifactId>base</artifactId>
<groupId>es.uniovi.innova</groupId>
<version>1.0.0</version>
</parent>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>ALL-DEPS</artifactId>
<version>1.0</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
</dependencies>
</project>
base
artifact, depends on javax.mail:mail-1.4.jar
, and ALL-DEPS
depends on another version of the same library. Due to the fact that mail.jar
from ALL-DEPS
exist on the execution environment, although not exported, collides with the mail.jar
that exists on the parent, which is scoped as compile
.
A solution could be to rid off mail.jar from the parent POM, but most of the projects that inherit base, need it (as is a transtive dependency for log4j). So What I would like to do is to simply exclude parent's library from the child project, as it could be done if base
was a dependency and not the parent pom:
...
<dependency>
<artifactId>base</artifactId>
<groupId>es.uniovi.innova</groupId>
<version>1.0.0</version>
<type>pom<type>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
</exclusions>
</dependency>
...
© Stack Overflow or respective owner