Archive for November, 2009

My first patch to Grails accepted

Monday, November 23rd, 2009

I recently wrote a patch for Grails to support dateCreated and lastUpdated when using mockDomain in unit tests.

This patch has now been applied to 1.2-SNAPSHOT.

http://jira.codehaus.org/browse/GRAILS-4540

The mockDomain method makes it possible to test code that uses GORMs dynamic methods, without having to use a real database.

IBM Developerworks has a great article on mock testing in Grails here.

How to debug grails run-app loop

Monday, November 9th, 2009

I recently had a problem where grails run-app would start the server, then immediately recompile 1 class, then restart… and repeat.

Google told me that the problem probably was an empty Java file in my project and to look in the ~/.grails/1.2-M4/projects/myproject/classes directory to see which file kept changing timestamp.

However, no files did that. The solution was to modify $GRAILS_HOME/scripts/_GrailsCompile.groovy and add listFiles:true to the compile target:

ant.groovyc(destdir:classesDirPath,
    classpathref:classpathId,
    encoding:"UTF-8",
    listFiles:true,
    compilerPaths.curry(classpathId, false))

And it turned out Google was right, I had a Java file with only the package specification in it.