Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven2: excluding directory from WAR

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?

like image 522
pls Avatar asked Sep 20 '10 09:09

pls


People also ask

How to exclude the folder from war maven?

maven-war-exclude-directory.mdpackagingExcludes configuration tag can be used to exclude certain files or directories from the war file. It is important to put '/' character at the end of the directory to be excluded. If there is no such '/' character, then the entry is interpreted as a regular file.

How to exclude files from war in maven?

It is possible to include or exclude certain files from the WAR file, by using the <packagingIncludes> and <packagingExcludes> configuration parameters.

What is packagingExcludes?

packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging. 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.


1 Answers

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> 
like image 121
Sean Patrick Floyd Avatar answered Sep 22 '22 15:09

Sean Patrick Floyd