Exclude all the jar's from webapp/WEB-INF/lib

Arpit picture Arpit · May 10, 2011 · Viewed 10.1k times · Source

I have the third party jar's in my WEB project placed at /src/main/webapp/WEB-INF/lib/

I have mentioned the dependency for all the required JAR's in the pom.xml. Now, Since the dependencies are defined in POM, the JAR's will be automatically packed in the lib folder.

  • I want to exclude all the JAR's in the lib.
  • The Dependency JAR's should be packaged inside the lib while building the WAR

I CANT DELETE THE LIB FROM WEB-INF BECAUSE ITS USED IN LOCAL DEVELOPMENT

This is what I've tried so far:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <packagingExcludes>META-INF/context.xml</packagingExcludes>
    <webResources>
      <resource>
        <directory>src/main/webapp/WEB-INF/lib</directory>
        <excludes>
          <exclude>**/**</exclude>
        </excludes>
      </resource>
    </webResources>
  </configuration>
</plugin>

Any Idea?

Answer

raven_arkadon picture raven_arkadon · Sep 16, 2012

It should be "packagingExcludes" instead of "warSourceExcludes":

<configuration>
    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
    ....
</configuration>

From http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html :

In version 2.1-alpha-1, this was incorrectly named warSourceExcludes