Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude resources from my maven build, packagingExcludes not working

I am using the maven-war-plugin to build a .war file

I am using packagigExcludes and it is working 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 are not getting exluded, I also tried:

src/main/resources/web.properties

This is a multi-module maven project, and I am building a .war file for this spring mvc maven project and I have to exclude these files but it isn't working.

Any pointers?

like image 627
Blankman Avatar asked Apr 22 '13 03:04

Blankman


2 Answers

i just tried ... are you sure you're 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 exlude stuff from resource, you would have to do this:

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <packagingExcludes>
                        WEB-INF/classes/log4j.properties
                    </packagingExcludes>
                </configuration>
            </plugin>
like image 100
rmalchow Avatar answered Sep 28 '22 14:09

rmalchow


Add this in pom.xml

</build>
  <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>web.properties</exclude>
            </excludes
        </resource>
  </resources>
</build>
like image 38
jmj Avatar answered Sep 28 '22 16:09

jmj