How to exclude resources from my maven assembly, packageExcludes not working

I am using maven-war-plugin to create a .war file

I use packagigExcludes and works fine for .jar files:

 <packagingExcludes>WEB-INF/lib/jetty-*.ja                        
                        WEB-INF/../resources/log4j.properties,
                        WEB-INF/../resources/web.properties
                    </packagingExcludes>

But the properties files above will not be excluded, I also tried:

src/main/resources/web.properties

This is a multi-module maven project, and I am creating a .war file for this spring mvc maven project, and I have to exclude these files, but it does not work.

Any pointers?

+5
source share
2 answers

I just tried ... are you sure you are doing the configuration in the right place? my pom looks like this:

<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.example</groupId>
        <artifactId>example-parent</artifactId>
        <version>0.1.4-SNAPSHOT</version>
    </parent>
    <artifactId>example-webapp</artifactId>
    <packaging>war</packaging>
    <url>http://maven.apache.org</url>
    <dependencies>
       [...]
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
        <finalName>example-webapp</finalName>
    </build>
</project>

----> EDIT

to exclude material from the resource, you will need to do this:

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <packagingExcludes>
                        WEB-INF/classes/log4j.properties
                    </packagingExcludes>
                </configuration>
            </plugin>
+9
source

Add this to pom.xml

</build>
  <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>web.properties</exclude>
            </excludes
        </resource>
  </resources>
</build>
+2
source

All Articles