Search code examples
javamavenmaven-2maven-pluginmaven-assembly-plugin

How to exclude folder with files from war maven assembly


I wanna exclude folder marked with red line. How can I do it?
enter image description here

Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>Test</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<url>http://maven.apache.org</url>
    <properties>
        <spring-version>4.1.0.RELEASE</spring-version>
        <spring-security-version>3.2.3.RELEASE</spring-security-version>
        <hibernate-version>4.3.4.Final</hibernate-version>
    </properties>

    <dependencies>
        <!-- a lot of dependencies -->
    </dependencies>
<build>
    <finalName>Test</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

Should I do anything with maven-compiler-plugin configuration?


Solution

  • This should give you the answer you need: http://maven.apache.org/plugins/maven-war-plugin/examples/including-excluding-files-from-war.html

    Here is an example where we exclude all JAR files from WEB-INF/lib:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
              <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
    

    This doesn't have anything to do with the maven compiler plugin, but the maven war plugin.