My blog has moved!

You will be automatically redirected to the new address. If that does not occur, visit
http://utku-utkan.appspot.com/
and update your bookmarks.

Pages

Friday, December 19, 2008

How to Exclude Web Resources in Maven 2

According to the maven-war-plugin documentation, Web resources can be excluded according to the following syntax.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
                <excludes>
                    <exclude>css/**</exclude>
                    <exclude>images/**</exclude>
                    <exclude>js/**</exclude>
                </excludes>
            </resource>
        </webResources>
    </configuration>
</plugin>

However, this syntax does not seem to be working. After investigating the source code, I realized that in fact this plugin expects an excludes element containing a comma separated list of patterns. Following is a sample that I have used successfully in one of my projects to exclude static content. You should also notice that, patterns are relative to the src/main/webapp folder.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <excludes>css/**,images/**,js/**</excludes>
    </configuration>
</plugin>