27 July 2014
How to avoid packaging unwanted folders on a java WAR file
You must use the maven-war plugin to enable this feature:
<modelVersion>4.0.0</modelVersion>
<parent> <artifactId>testAppWebParent</artifactId> <groupId>io.guilhebl.test</groupId> <version>1.0.0</version> <relativePath>../testAppWebParent/pom.xml</relativePath> </parent>
<artifactId>testApp</artifactId> <packaging>war</packaging> <name>Test Application</name>
<span class="nt"><properties></span>
<span class="nt"><endorsed.dir></span>${project.build.directory}/endorsed<span class="nt"></endorsed.dir></span>
<span class="nt"><org.apache.maven.plugins.maven-war-plugin.version></span>2.3<span class="nt"></org.apache.maven.plugins.maven-war-plugin.version></span>
<span class="nt"></properties></span>
<span class="nt"><dependencies></span>
<span class="nt"></dependencies></span>
<span class="nt"><build></span>
<span class="nt"><plugins></span>
<span class="nt"><plugin></span>
<span class="nt"><groupId></span>org.apache.maven.plugins<span class="nt"></groupId></span>
<span class="nt"><artifactId></span>maven-war-plugin<span class="nt"></artifactId></span>
<span class="nt"><version></span>${org.apache.maven.plugins.maven-war-plugin.version}<span class="nt"></version></span>
<span class="nt"><configuration></span>
<span class="nt"><warSourceExcludes></span>test/**,scripts/**,node_modules/**,bower_components/**<span class="nt"></warSourceExcludes></span>
<span class="nt"></configuration></span>
<span class="nt"></plugin></span>
<span class="nt"></plugins></span>
<span class="nt"></build></span>
</project>
The resulting WAR file will not have the above folders packaged as a result of the build, resulting in a smaller, more compact WAR file.