Thursday, April 30, 2009

Adjusting maven to the eclipse GAE project

As I mentioned in my previous post. The war directory location in the eclipse project cannot be changed, the GAE plugin wont understand this. Instead we have to adapt maven to this.

First off, enable maven for the project. Just create the pom.xml with some basic content.

<project xmlns="http://maven.apache.org/POM/4.0.0" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelversion>4.0.0</modelversion>
<groupid>com.appspot</groupid>
<artifactid>maven</artifactid>
<packaging>war</packaging>
<name>maven</name>
<version>0.0.1-SNAPSHOT</version>
</project>

Now, change the war directory in maven by adding a plugin configuration for maven war plugin and set the war source directory.

<build>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins</groupid>
<artifactid>maven-war-plugin</artifactid>
<version>2.0</version>
<configuration>
<warSourceDirectory>${basedir}/war</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>

After this you can update your project configuration from maven and it'll work out pretty well. However, eclipse will display an error about the target directory is not corret. Just click quickfix and then accept the change and it is corrected.

To be able to run the bundled jetty server via the eclipse plugin, you must run mvn war:inplace to add the maven managed libraries to the WEB-INF/lib directory.

No comments:

Post a Comment