Marketing digital. Making results.

Maven WAR plugin: Copying resources to another folder

For the purpose of building an exploded war for my application I am using the maven-war-plugin. There is a common set of UI files that are used by the applications i am working so they’ve been exported to their own SVN folder and the build process copies this folder to the final WAR or exploded war directory. After playing with my POM for a while and trying the maven-resources-plugin without much success, i ran into the <webResources> property of the maven-war-plugin. This is the maven-resources-plugin functionality adapted to the maven war plugin. I originally set up my configuration as such:

  <plugin>   <groupId>org.apache.maven.plugins</groupId>   <artifactId>maven-war-plugin</artifactId>   <version>2.0</version>   <configuration>   <webappDirectory>c:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\${project.artifactId}-${env}</webappDirectory>   <webResources>   <resource>   <targetPath>common</targetPath>   <filtering>false</filtering>   <directory>C:\eclipseGalileo\eclipse\workspace\common</directory>   <includes>   <include>**/*.*</include>   </includes>   <excludes>   <exclude>**/*.svn</exclude>   </excludes>   </resource>   </webResources>   </configuration>   </plugin>  

No luck in getting it work although there were no errors in syntax, all the files in the “common” directory just were getting copied to the root of my webapp directory in my exploded war no matter what the path was i specified
for “targetPath”. The simple fix for that was to upgrade my version of the plugin to 2.1 as such:

<artifactId>maven-war-plugin</artifactId>  <version>2.1</version>  

Et voila! Problem solved.