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?
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:Had a scenario where I had to exclude two folders which could be matched by
*scripts
and they were in the resources folder. The first confusion was whether to provide the exclude value assrc/main/resources/*scripts
or asWEB-INF/classes/*scripts
, i.e. pre or post compilation structure.Was much important to provide
/**
to get the entire directory being excluded from the war file. In my case,*scripts/**
.Here is the final configuration which worked:
In version 2.1-alpha-1, this was incorrectly named warSourceExcludes. The right parameter is packagingExcludes
Example of usage (excludes WEB-INF/statics/ folder from WAR):
Inorder to remove the source files i have used the below configuration in maven
warSourceExcludes seems not to have been just renamed packagingExcludes.
There is a big difference: With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file. As a result, if the tokens are present in the webappDirectory for example, they will not be ignored when using warSourceExcludes but will be when using packagingExcludes.
And a working syntax example: