Senior Java developer, one of the top stackoverflow users, fluent with Java and Java technology stacks - Spring, JPA, JavaEE. Founder and creator of http://computoser.com and http://welshare.com . Worked on Ericsson projects, Bulgarian e-government projects and large scale recruitment platforms. Member of the jury of the International Olympiad in Linguistics and the Program committee of the North American Computational Linguistics Olympiad. Bozhidar is a DZone MVB and is not an employee of DZone and has posted 81 posts at DZone. You can read more from them at their website. View Full User Profile

Google App Engine and Maven

09.01.2011
| 6510 views |
  • submit to reddit

I created a small project that I wanted to host somewhere for free. Amazon free tier or Google App Engine? I already have experience with AWS, so I decided to try GAE. It is completely different, of course. And it didn’t start quite well, with some NullPointerExceptions from the eclipse plugin. But ultimately, it worked fine. However, I was a bit confused how to use Maven in a GAE project. By default, everything should go to the /war directory, and that’s not maven’s directory structure. And this post scared me even more – the pom.xml looks appalling. What I ultimately achieved is workable, and the pom remains simple.

  • mavenzie your project (m2eclipse). Update project configuration to have everything in place
  • In right click > Properties > Google > Web applications have the path pointing to “target/project-0.0.1-SNAPSHOT” (or whatever your assembly folder is), and uncheck the “launch and deploy from this directory”.
  • Move everything from “war” to “src/main/webapp”. Parhaps without the jars, which you can add as maven dependencies
  • run maven > package, so that the target directory is populated
  • Right click > Deploy to Google App Engine – it will ask you for a directory the first time – choose “…/target/project-0.0.1-SNAPSHOT” again (this is absolute path). It will remember this decision, but don’t commit the .settings/com.google.gdt.eclipse.core.prefs, because it now contains an absolute path

That way everything works fine. Before each deploy you should make a maven build, but that’s not that bad (well, generally speaking, it is bad, but you don’t have hot-deploy here anyway. And my build is really quick. If I had a huge project with a very long build, I wouldn’t go for GAE, but that’s just my opinion)

 

 From http://techblog.bozho.net/?p=494

Published at DZone with permission of Bozhidar Bozhanov, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Kai Wähner replied on Fri, 2011/09/02 - 12:40pm

GAE + Maven setup? This is one of the use cases where Spring Roo is awesome for getting started.

You can create a GAE project within seconds. Roo uses Maven by default. It makes all the setup for you. Then you can start developing a GAE app and remote Roo if you want...

 

Best regards,

Kai Wähner (Twitter: @KaiWaehner)

John David replied on Thu, 2012/01/26 - 3:23am

The proper way of solving the interoperability issues with Maven and Google Plugin for Eclipse would be a m2e extension (like the one for Android projects). Already twice I’ve started that project, just to realize that the complexity of Eclipse together with m2e and Maven is way too much for me to be even able to set up a trivial project! I feel like banging my head against the wall. So if you or anyone else have any tips, they’d be greatly appreciated.

I’ve been more comfortable doing the deployment via the maven-gae-plugin instead of Eclipse. Just by typing mvn gae:deploy it does all the magic.

Java Eclipse

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.