Maven2 / WAR / Eclipse Dynamic Web Project

Here's a example pom.xml for a typical eclipse dyn. web project with the following directory structure :

  • <project_root>
  • pom.xml
  • src/
    • *.java, .properties etc.
  • WebContent/
    • WEB-INF/


<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <parent>
            <groupId>com.xyz</groupId>
            <artifactId>blah</artifactId>
            <version>0.1</version>
    </parent>
    <artifactId>blah-web</artifactId>
    <packaging>war</packaging>
    <name>Blah Web</name>
    <dependencies>
        <dependency>
            <groupId>${pom.groupId}</groupId>
            <artifactId>blah-core</artifactId>
            <version>${pom.version}</version>
       </dependency>
        <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
                <groupId>net.sourceforge.stripes</groupId>
                <artifactId>stripes</artifactId>
                <version>1.4.2</version>
        </dependency>
        <dependency>   
                <groupId>org.acegisecurity</groupId>
                <artifactId>acegi-security</artifactId>
                <version>1.0.3</version>
        </dependency>
        <dependency>   
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
              <version>1.4</version>
        </dependency>
        <dependency>   
                <groupId>freemarker</groupId>
                <artifactId>freemarker</artifactId>
                <version>2.3.8</version>
        </dependency>
        <dependency>   
                <groupId>net.sourceforge.jfacets</groupId>
                <artifactId>jfacets</artifactId>
                <version>1.3.5</version>
        </dependency>
        <dependency>
                <groupId>taglibs</groupId>
                <artifactId>standard</artifactId>
        </dependency>
        <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
        </dependency>

</dependencies>
        <build>
                <sourceDirectory>${basedir}/src</sourceDirectory>
                <outputDirectory>${basedir}/target/classes</outputDirectory>
                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-war-plugin</artifactId>
                                <version>2.0</version>
                                <configuration>
                                        <warName>blah</warName>
                                        <warSourceDirectory>${basedir}/WebContent</warSourceDirectory>
                                        <warSourceExcludes>**/*.jar</warSourceExcludes>
                                </configuration>
                        </plugin>
                </plugins>
        </build>
</project>