Sunday, May 31, 2009

Google App Engine with Maven

Google App Engine has an Eclipse plugin to help with uploading and enhancing your JDO classes. It also sets up the dependancies and exposes the GAR API. Very handy. But it doesn't play nicely with maven because the two of them assume a different project layout. Maven expects your webapp source to live under src/main/webapp/ and it builds an exploded war under target/ . Meanwhile, the Google App Engine plugin for eclipse is hardcoded to look for both source and target under the root folder war/

The google team will probably allow this configuration soon but until then you can update your maven pox.xml like this:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<directory>war</directory>
<warSourceDirectory>war</warSourceDirectory>
<webappDirectory>war</webappDirectory>
</configuration>
</plugin>

You may also need to create a appengine-web.xmlfile under war/WEB-INF/ to get the plugin to work if you are using appengine on an existing project.

Thursday, May 14, 2009

Maven error

In case someone comes accross the same problem - I came hit this exception and fixed it by deleting my target directory and clean-ing the project from Eclipse to rebuild the classes.

[INFO] [war:war]
[INFO] Packaging webapp
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] modelEncoding : modelEncoding
---- Debugging information ----
message : modelEncoding : modelEncoding
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : modelEncoding : modelEncoding
class : org.apache.maven.plugin.war.util.WebappStructure
required-type : org.apache.maven.model.Dependency
path : /webapp-structure/dependenciesInfo/org.apache.maven.plugin.war.util.DependencyInfo/dependency/modelEncoding
line number : 1108
-------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Trace
com.thoughtworks.xstream.converters.ConversionException: modelEncoding : modelEncoding
---- Debugging information ----
message : modelEncoding : modelEncoding
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : modelEncoding : modelEncoding
class : org.apache.maven.plugin.war.util.WebappStructure
required-type : org.apache.maven.model.Dependency
path : /webapp-structure/dependenciesInfo/org.apache.maven.plugin.war.util.DependencyInfo/dependency/modelEncoding
line number : 1108
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:63)