Blog

HOW-TO: GAE + Eclipse + Maven

  • App Engine
  • AppEngine
  • archetype
  • Eclipse
  • GAE
  • Google App Engine
  • Guestbook
  • Java
  • Maven
  • Maven 2
  • Programming

Help me in making the integration of GAE, Eclipse and Maven smoother and star this issue in AppEngine

Update: This solution doesn't work on Eclipse 3.6 Helios and newest version of m2eclipse, check out the new solution if you're on the newer version.

Nowadays everybody wants to manage their Java projects with Maven. And that's totally sensible since Maven makes some things pretty damn easy, mostly because there's a plugin for about everything. Yes, there is a plugin for Google App Engine (GAE) too, with which you can run the local development server and deploy your app. The same features are available on the Google Plugin for Eclipse, which is the Google preferred way to develop Java-based App Engine applications. So of course you'd like to also utilize the IDE integration, especially when the startup time of the local GAE development server is significally faster, thus increasing your productivity. So far, the problem has been, how to enjoy the benefits of both worlds, and I've have to tell you, it is now solved. Another thing I have to tell you is, how, so here we go.

Requirements

The integration isn't compatible with m2eclipse, but it's required for attaching the Maven war:exploded goal to Eclipse compilation. Also the integration is not perfectly production ready since it has to rely on a snapshot version of maven-eclipse-plugin hosted at Bearded Geeks' Maven repository. It's required for linkedResource configuration and using the Eclipse Java Compiler. For more details see plugin's issue tracker for linkedResources and output classes (Voting on the issues and by other means trying to get the patches in will be highly appreciated).

So, I've converted the Guestbook Example into a Maven managed one and I'm distributing it as a Maven archetype. So, here's how you begin:

mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate \
  -DarchetypeGroupId=org.beardedgeeks \
  -DarchetypeArtifactId=gae-eclipse-maven-archetype \
  -DarchetypeVersion=1.1.2 \
  -DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/releases

By running that command you can create a Maven managed GAE app of your own. Just remember to change everything to match your application, like appId etc. To enable Eclipse integration run mvn eclipse:eclipse. After that you'll need to import the project to Eclipse and after that and few project refreshs you should be fine (don't mind it giving warnings about some missing libraries, they shouldn't affect). Just run it as you usually run App Engine projects in Eclipse. Also on every Eclipse startup the Eclipse might put its GAE libraries back to war/WEB-INF/lib which'll cause failure on startup, but cleaning the project solves the problem. You can also run your project using maven-gae-plugin by typing mvn gae:run on command line or deploy to App Engine by typing mvn gae:deploy.

If you're not that into archetypes, you can find the project sources through SVN at Bearded Geeks' Google Code project. The guestbook example can be found up and running at the project's GAE page.