I am trying to control which files make into the WAR package that is created by mvn package
goal. Specifically, I want to exclude some files from the default src/main/resources
folder for each package (I am trying to do builds/package for different environments).
I tried using maven-war-plugin but failed. If I add this configuration (for testing):
<webResources>
<resource>
<directory>src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
<excludes>
<exclude>*.xml</exclude>
</excludes>
</resource>
</webResources>
...my WEB-INF/classes
will still contain the XML files. This is because webResources
parameter seems to duplicate the copying process (the above configuration actually works, an files are not copied... but they get copied in some other process instead).
Maven-war-plugin documentation states:
The default resource directory for all Maven 2 projects is src/main/resources which will end up in target/classes and in WEB-INF/classes in the WAR. The directory structure will be preserved in the process.
The WAR Plugin is also capable of including resources not found in the default resource directory through the webResources parameter.
This is a bit confusing. Does it mean that:
- The
webResources
parameter is a feature in maven-war-plugin that allows files to be included only from outsidesrc/main/resources
folder? If so, how can we alter the copied files from insidesrc/main/resources
? - The
webResources
parameter is a feature in maven-war-plugin that allows files to be included also from outsidesrc/main/resources
folder? If so, how can it be configured to do this? - Some other option?