Monday, December 27, 2010

Enabling Hot-Deploy in Gaelyk/Google App Engine with IntelliJ IDEA

I've been getting into Gaelyk lately, a lightweight Groovy-based web framework for Google's App Engine. My preferred development environment is, at the moment, Intellij IDEA (now at version 10), and I was happy to find this excellent post by Said Eloudrhiri which itemized exactly how to do just that (to be perfectly clear I had mostly setup my system prior to reading his post, so my version may not be exactly the same).

I've been enjoying working with Gaelyk in IDEA, but had one nagging problem - normally when you edit a resource (groovlet, gtpl file, etc) in Gaelyk/GAE(at least in development mode), the server automatically deploys the change and you see it take effect almost instantly. That wasn't happening, forcing me to restart the server every time I made a change. Not great. I tried running the dev server from the command line, and my edits would take effect right away, as expected, so it was obviously an IDEA issue.

Turns out that IDEA doesn't just fire up the server and go - it actually uses a separate directory as the app root, basically running as if from an exploded WAR file, separate from the 'war' directory were the resource files are stored. I finally figured out how to fix this, but for a better explanation, I'll turn to Said again, who answered this same question (again!) in the comment thread of his post:

The reason why IntelliJ is not able to detect and to hot deploy your changes is because by default the generated Artifacts uses an “out” folder.
This means that when you run your deployment, IntelliJ builds and generates your project into the “out” folder as another “war exploded” archive.
When you run your server locally, Jetty uses the application found in the “out” folder while your sources are located in another folder (“war” by default).

He follows with a list of steps, that I'll try to better document here (AFAIK, the only explanation of this online is the referenced comment):


Right-Click on your Gaelyk Project in IDEA, and select "Open Module Settings".


Uncheck "Build on Make".




Removed selected text (the IDEA output directory path). There's no need to actually remove the directory.



Replace the output path with the directory where your files are actually stored ('war', with a standard configuration).

Click "Apply", restart the server within IDEA, and you're all set!

Thanks again to Said for the tip!

No comments:

Post a Comment