Milos Zikic - Personal site, sharing thoughts about startups, products and engineering

Maven war plugin and non default webapp folder

Yesterday I started mavenizing some old project (with a lot of messy legacy code that needs refactoring, but thats another story :) and it took me half an hour to figure one small thing that was in front of my eyes. Therefor I want to share this with you so you can note the same if you need it somewhere.


It is common war project with a non default maven webapp folder. In order to fix this I configured war plugin to use a nonstandard webapp folder by using configuration element: webappDirectory


<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1-beta-1</version>
        <configuration>
          <webappDirectory>web</webappDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>


And this worked but I found out that I was getting .svn metadata copied to resulting war. This was very awkward for me so I tried to use packagingExcludes and making ignore list and then after about half an hour discovered that proper attribute should be warSourceDirectory and not webappDirectory. The later one is used to specify where webapp will finish and it is used to pack war file from there so I didn't notice my mistake at first.


After changing to warSourceDirectory everything behaved normally and expected. Full reference of available options for war plugin are available at: http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html.


Hope that this post helped someone not to loose 30 minutes going into wrong direction :)

Comments

Anonymous
Thank you
Koray
Thanks. Great.
Koray
great thanks
Anonymous
It helped me, thank you :-)

Share this post