How to exclude dependency in a Maven plugin?
Asked Answered
G

2

60

I have a project that needs the following Maven jibx plugin:

  <build>
    <plugins>
      <plugin>
        <groupId>org.jibx</groupId>
        <artifactId>maven-jibx-plugin</artifactId>
        <version>1.2.2</version>
        ...
      </plugin>
    </plugins>
  </build>

Inside the jibx plugin pom, there is a xpp3 dependency which I want to exclude from my project build process (due to some reason I cannot have it inside my private repository).

Is there a way to config my pom.xml (not the plugin pom) to exclude that dependency?

EDIT: I tried to remove the xpp3 dependency from the plugin pom and the project could be built successfully, so I know the dependency is not mandatory.

Grizel answered 17/5, 2011 at 9:2 Comment(2)
Have you seen jira.codehaus.org/browse/MNG-2448 ?Arbuthnot
@Tomasz MNG-2448 is about dependency overriding. However, thanks for your link, I found http://jira.codehaus.org/browse/MNG-2163, which shows that plugin dependency exclusion is still an open issue.Grizel
O
47

Here is an example where the jetty-maven-plugin has a dependency on jtidy replaced with a newer version:

http://jira.codehaus.org/browse/JETTY-1339?focusedCommentId=257747&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_257747

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>net.sf.jtidy</groupId>
            <artifactId>jtidy</artifactId>
            <version>r938</version>
          </dependency>
          <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-tools-api</artifactId>
            <version>2.5.1</version>
            <exclusions>
              <exclusion>
                <groupId>jetty</groupId>
                <artifactId>jetty</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
        </dependencies>
[...]
      </plugin>
Otology answered 13/9, 2011 at 17:23 Comment(3)
Where does the <groupId>org.apache.maven.plugin-tools</groupId> part come from? Is this example excluding a transitive dependency of jetty?Runaway
It does not seem to work with direct dependencies. Unless the groupId and artifactId are the same.Dunnage
I observed the same as @ArchimedesTrajano and asked a new question.Pegu
G
0
 3.23.1-GA is the new version added to solve the err
 java.io.ioexception invalid constant type 19 at 4

 <dependency>
 <groupId>org.javassist</groupId>
 <artifactId>javassist</artifactId>
 <version>3.23.1-GA</version>
 </dependency>
 Find out which transitive dependency bring the older version of 
 javassist and 
add then as below and adding exclusion like below the issue can be solved

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
 <version>${hibernate.version}</version>
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
 </exclusion>
</exclusions>
</dependency>
Guilder answered 18/4, 2022 at 11:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.