How to exclude jars generated by maven war plugin?

Jacques René Mesrine :

Because of transitive dependencies, my wars are getting populated by xml-apis, xerces jars. I tried following the instructions on the reference page for maven-war-plugin but it is not working.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <packagingExcludes>WEB-INF/lib/xalan-2.6.0.jar,WEB-INF/lib/xercesImpl-2.6.2.jar,WEB-INF/lib/xml-apis-1.0.b2.jar,WEB-INF/lib/xmlParserAPIs-2.6.2.jar</packagingExcludes>
      <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
      <warName>project1</warName>
      <warSourceDirectory>src/main/webapp</warSourceDirectory>
    </configuration>
</plugin>

What am I doing wrong ? If it matters, I discovered that the maven-war-plugin I'm using is at version 2.1-alpha-1

David Rabinowitz :

You can mark these dependencies as provided:

<dependency>
  <groupId>xerces</groupId>
  <artifactId>xerces</artifactId>
  <version>2.4.0</version>
  <scope>provided</scope>
</dependency>

This way the maven will add them to the compilation classpath, but will not package them. It is assumed they exist in your servlet container.

See more about maven scopes here under "scope"

Edit If you want to remove classes added via transitive dependencies you can exclude them from the dependency like this:

<dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring</artifactId>
        <version>2.5.6</version>
        <exclusions>
                <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                </exclusion>
        </exclusions>
</dependency>

(taken from this answer)

See more here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Maven war plugin archiveClasses but exclude a package

From Dev

Maven Launch4j Plugin - how to configure to exclude jars used by the .exe?

From Dev

exclude WEB-INF from a maven generated war

From Dev

maven - how to exclude an entire module on from war

From Dev

Filtering in maven-war-plugin does not exclude directory

From Java

maven-war-plugin: exclude all directories but one

From Dev

Maven - How to exclude dependencies from generated JAR

From Java

How configure maven-war-plugin for tomcat

From Dev

How to filter applicationContext using maven war plugin

From Java

How to exclude a direct dependency of a Maven Plugin

From Dev

Maven: How to exclude a plugin with a custom flag

From Dev

Maven cannot find jars of package shipped as war

From Dev

Using Maven-bundle-plugin, how can i package dependent jars as .class (extracted jars)

From Dev

maven exclude plugin in dependency

From Dev

Maven 3: How to exclude generated sources from Xlint check?

From Dev

How to exclude logs generated by maven dependencies in slf4j?

From Dev

How to include JARs in WAR archive WEB-INF/lib using Maven?

From Java

How to Include specific jars in WAR, WEB-INF/lib directory with maven

From Dev

Maven is not putting generated jars into the local repository

From Java

How to bundle a war inside a package/.zip using maven assembly plugin

From Dev

wrong configuration of maven war plugin

From Dev

Maven assembly plugin: dependency jars are not included, fat jar without jars

From Java

How to exclude a file in the source root from Maven Checkstyle plugin checks?

From Dev

How to exclude project dependency from classpath used by maven plugin

From Dev

How can I exclude empty folders with Asciidoctor maven plugin

From Java

How to exclude dependencies from maven assembly plugin : jar-with-dependencies?

From Dev

How to exclude jasperreports artifact from jasperreports maven plugin

From Dev

How to use maven assembly plugin to exclude a package from dependency jar?

From Dev

How to exclude transitive dependencies with scope provided with maven-assembly-plugin?

Related Related

  1. 1

    Maven war plugin archiveClasses but exclude a package

  2. 2

    Maven Launch4j Plugin - how to configure to exclude jars used by the .exe?

  3. 3

    exclude WEB-INF from a maven generated war

  4. 4

    maven - how to exclude an entire module on from war

  5. 5

    Filtering in maven-war-plugin does not exclude directory

  6. 6

    maven-war-plugin: exclude all directories but one

  7. 7

    Maven - How to exclude dependencies from generated JAR

  8. 8

    How configure maven-war-plugin for tomcat

  9. 9

    How to filter applicationContext using maven war plugin

  10. 10

    How to exclude a direct dependency of a Maven Plugin

  11. 11

    Maven: How to exclude a plugin with a custom flag

  12. 12

    Maven cannot find jars of package shipped as war

  13. 13

    Using Maven-bundle-plugin, how can i package dependent jars as .class (extracted jars)

  14. 14

    maven exclude plugin in dependency

  15. 15

    Maven 3: How to exclude generated sources from Xlint check?

  16. 16

    How to exclude logs generated by maven dependencies in slf4j?

  17. 17

    How to include JARs in WAR archive WEB-INF/lib using Maven?

  18. 18

    How to Include specific jars in WAR, WEB-INF/lib directory with maven

  19. 19

    Maven is not putting generated jars into the local repository

  20. 20

    How to bundle a war inside a package/.zip using maven assembly plugin

  21. 21

    wrong configuration of maven war plugin

  22. 22

    Maven assembly plugin: dependency jars are not included, fat jar without jars

  23. 23

    How to exclude a file in the source root from Maven Checkstyle plugin checks?

  24. 24

    How to exclude project dependency from classpath used by maven plugin

  25. 25

    How can I exclude empty folders with Asciidoctor maven plugin

  26. 26

    How to exclude dependencies from maven assembly plugin : jar-with-dependencies?

  27. 27

    How to exclude jasperreports artifact from jasperreports maven plugin

  28. 28

    How to use maven assembly plugin to exclude a package from dependency jar?

  29. 29

    How to exclude transitive dependencies with scope provided with maven-assembly-plugin?

HotTag

Archive