maven2: excluding directory from WAR

pls picture pls · Sep 20, 2010 · Viewed 47.6k times · Source

I tried this to exclude whole directory (${basedir}/src/main/webapp/webscripts) from my WAR file but it failed. What is wrong?

this doesn't work:

<configuration>
   <webResources>
      <resource>
       <directory>${basedir}/src/main/webapp/webscripts</directory>
       <excludes>
        <exclude>**/*.*</exclude>
       </excludes>
      </resource>
   </webResources>
</configuration>

this too:

<configuration>
   <webResources>
      <resource>
       <directory>${basedir}/src/main/webapp</directory>
       <excludes>
        <exclude>**/webscripts</exclude>
       </excludes>
      </resource>
   </webResources>
</configuration>

Can anybody help?

Answer

Sean Patrick Floyd picture Sean Patrick Floyd · Sep 20, 2010

Both of your solutions wouldn't help, as they would add an additional resource that is then deactivated. The webapp source folder is copied by default, without the resource mechanism.

The mechanism to deactivate a part of that is through the <warSourceExcludes> parameter, like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <warSourceExcludes>webscripts/**</warSourceExcludes>
    </configuration>
</plugin>