How to Exclude Dependency in a Maven Plugin?

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.

2

2 Answers

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

    <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>
3
 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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest