Pages

Thursday, February 26, 2009

Setting Up A New Web Application Using Eclipse, Maven, Ant and Tomcat

Create a new application structure using maven

mvn archetype:create -DgroupId=com.zeltov.appstore -DartifactId=appstore2 -DarchetypeArtifactId=maven-archetype-webapp

Create Eclipse project

mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true

In Eclipse import as a maven project

Modify the pom.xml file:

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>${taglibs-standard-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl-version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>

<spring-version>2.5.6</spring-version>
<junit-version>4.1</junit-version>
<jstl-version>1.2</jstl-version>
<taglibs-standard-version>1.1.2</taglibs-standard-version>
<servlet-api-version>2.5</servlet-api-version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>info.jtrac</groupId>
<artifactId>maven-antprops-plugin</artifactId>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>jtrac.info</id>
<url>http://j-trac.sourceforge.net/repository</url>
</pluginRepository>
</pluginRepositories>


Next Run an ant command to generate the jar dependencies property file


mvn antprops:generate


To download mvn dependencies with sources:

mvn dependency:sources


Maven Ant Integration Tutorial by Peter Thomas great way to do dependency management and use ant at the same time

Article to create a java app and then a webapp as 2 seperate projects using maven

No comments:

Post a Comment