Grails is all about convention-over-configuration, and in most cases that idea works just fine. Sometime that idea isn’t so great.

The Grails App engine plugin provides an example of this. When packaging and deploying a new version of your app, the grails appengine task generates the appengine-web.xml file for you automatically. This file is used by Google App Engine to configure your app. The problem I faced recently is that I needed to make a change to this file, and there was no way to do it without modifying the GANT task that generates the file. Which is what I did.

In my case I wanted to enable the handy logging mechanism provided by Google AppEngine. GAE uses the java.util.logging framework to accomplish this as documented here.

I copied the logging.properties file to: MY_GRAILS_APP/web-app/WEB-INF

Then to point to my logging.properties file, I had to modify the GANT task that generates the appengine-web.xml file.

USER_HOME/.grails/1.1.1/projects/MY_GRAILS_APP/plugins/app-engine-0.8.5/scripts/_Events.groovy

I modified the section that stamps out the appengine-web.xml file to look like this:

println "Generating appengine-web.xml file for application [$appName]"	
	new File("$stagingDir/WEB-INF/appengine-web.xml").write """<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application>${appName}</application>
    <version>${appVersion}</version>
    <sessions-enabled>${enableSessions}</sessions-enabled>
    <ssl-enabled>${enableSsl}</ssl-enabled>
	<system-properties>
	    <!-- this property should be necessary. it avoids the report of an abnormal and unexpected situation!
	        <property name="appengine.orm.disable.duplicate.emf.exception" value="true" />
	     -->
	     <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    </system-properties>
 
</appengine-web-app>

After running a grails app-engine deploy, the new version of the app was deployed and the log messages came through in my Google App Engine Dashboard.

Perhaps in future releases of the grails app engine plugin, a better way will be provided to make changes to the appengine-web.xml file.