My project depends on org.apache.pig:pig
but I don't want the transitive dependencies of org.mortbay.jetty:jetty
and org.mortbay.jetty:servlet-api
. I added these two artifacts as <excludes>
but that doesn't seem to work:
mvn dependency:tree -Dincludes=org.mortbay.jetty:servlet-api
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - myGroupp:myArtifact:jar:1.0-SNAPSHOT
[INFO] task-segment: [dependency:tree]
[INFO] ------------------------------------------------------------------------
[INFO] [dependency:tree {execution: default-cli}]
[INFO] myGroupp:myArtifact:jar:1.0-SNAPSHOT
[INFO] \- org.apache.pig:pig:jar:0.10.0:compile
[INFO] \- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] \- org.mortbay.jetty:servlet-api:jar:2.5-20081211:compile
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>myGroupp</groupId>
<artifactId>myArtifact</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.pig</groupId>
<artifactId>pig</artifactId>
<version>0.10.0</version>
<exclusions>
<exclusion>
<artifactId>org.mortbay.jetty</artifactId>
<groupId>jetty</groupId>
</exclusion>
<exclusion>
<artifactId>org.mortbay.jetty</artifactId>
<groupId>servlet-api</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
I've tried this with: mvn --version
Can someone help me exclude this?
Exclusions are set on a specific dependency in your POM, and are targeted at a specific groupId and artifactId. When you build your project, that artifact will not be added to your project's classpath by way of the dependency in which the exclusion was declared.
Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.
You have artifactId and groupId element values transposed.
Try these exclusions instead:
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
</exclusion>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With