How to exclude jars from maven dependency when packaging?

240 Views Asked by At

I'm trying to package a jboss AS7.5 module (RedHat EAP 6.4) that includes a valve. That valve requires a binding to the AuthenticatorBase that comes with the tomcat-catalina-x.y.z.jar, which does not (to my knowledge) come as a downloadable module in its own right. So, I need to build that jar into my module, using the maven plugin for packaging with dependencies.

Problem is, the GAV for the dependency, org.apache.tomcat:tomcat-catalina:x.y.z, includes libraries that ARE included in AS, namely the servlet libraries. If I package the catalina dependency, using the maven plugin that does that, I get a bunch of unnecessary jars that break my module at runtime.

Is there a way to

  1. only package the jar(s) I want?
  2. find a different dependency that includes just the tomcat valve (i.e., the jar containing org.apache.catalina.authenticator.AuthenticatorBase) binding?

or, preferably, is there a module that already exists for exactly this purpose, one that I can reference as a module dependency in my module.xml file?

<dependencies>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>${tomcat-catalina.version}</version>
    </dependency>
    ...
</dependencies>

includes jars: tomcat-catalina, tomcat-servlet, tomcat-juli, tomcat-annotations, etc.

<build>
    <plugins>
        <plugin>
            <!-- NOTE: We don't need a groupId specification because the group is 
                org.apache.maven.plugins ...which is assumed by default. -->
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
   ...
   </plugins>
</build>

How to get only tomcat-catalina.jar in my packaged module?

0

There are 0 best solutions below