I started working on a Google App Engine project the usual way: using the Eclipse plugin. However, unfortunately the update to the latest Eclipse plugin broke it and I haven’t found a fix yet. So I decided to try the maven-gae-plugin, once again; with Maven everything
runs builds better anyway, right? So far I had only made some minor tests with the plugin.
For mavenizing the project I went the safe route: I created a new project with the maven archetype plugin:
mvn archetype:create\ -DarchetypeGroupId=net.kindleit\ -DarchetypeArtifactId=gae-archetype-gwt\ -DarchetypeVersion=0.5.0\ -DgroupId=your.groupId\ -DartifactId=your-artifactId\ -DremoteRepositories=http://maven-gae-plugin.googlecode.com/svn/repository
The project itself was only temporary, I was interested in the pom.xml file. I updated that file accordingly (e.g. the plugin version of the file was not the latest), removed GWT sections as I don’t use GWT in my project and changed some minor settings and added all required dependencies. Finally I copied the pom.xml into my project directory.
Then I made a lot of modifications within Eclipse – moved sources to standard Maven locations, removed JAR files etc. and was about to commit everything – but unfortunately Subversion detected a bunch of tree conflicts. Bummer. While resolving these conflicts seem to be hard, I decided to check out the project into another directory and start changing the structure from scratch – this time not using Eclipse but Subversion command line tools. That worked perfectly.
mvn gae:run I started the development server. Startup was really smooth. However, by default the server is started on localhost only, but in my project I need a specific IP address as I need to access the server from the iPhone, too. Therefore I had to set the
gae.address property. Of course it can be defined in pom.xml, but then it is the same for all development machines. I don’t want that. Therefore it must be defined in the users’s ~/.m2/settings.xml:
<profiles> <profile> <id>gae</id> <properties> <gae.address>192.168.178.24</gae.address> </properties> </profile> </profiles> <activeProfiles> <activeProfile>gae</activeProfile> </activeProfiles>
Now the server runs on the right IP address.
Now with using Maven I did not want to get rid of the ability to debug my application. How can this be done? Easy. First of all, the plugin provides the
mvn gae:debug goal. When running this goal, the development server starts in debug mode.
In Eclipse a new
run debug configuration has to be created.
- In the Console run
mvn gae:debug; Maven will compile, execute tests and start the development server in debug mode.
- Wait until the server waits for the remote debugger; you will see the following output: “Listening for transport dt_socket at address: 8000″. The address is in this case the port, which needs to be set in the Eclipse debug configurations.
- In Eclipse go to Run > Debug Configurations …
- Create a new “Remote Java Application” configuration
- Give it a good name, choose Connection Type “Standard (Socket Attach)” and set the Connection Properties (in my case Host: 192.168.178.24, Port: 8000)
- Click on “Debug”. Now you see that the development server in the console continues.
Now everything works as good as when using the Eclipse plugin, right? Not quite. There is one thing that doesn’t work: dynamic reload of webpages, such as JSP or CSS files. Jetty allows dynamic reload, but when using Maven, Jetty does not use the src/main/webapp folder as working directory; instead it uses its own directory somewhere in target/…
To avoid long edit / build / deploy / run cycles, the recommended way at the moment is to run
mvn gae:run in one console window and
mvn cli:execute in another window. The command line interface allows you to quickly execute Maven goals. Run
compile war to update the webpages in the development server’s working directory.
While this is not quite as simple as with Eclipse, it is a workaround that speeds up the development process significantly.