Thursday, September 2, 2010

Patching Grails

If you want to add a fix to Grails without waiting for next release, here is what I have done to patch it's jars. Basically it's two steps. First, compile patched source code to classes. Second, sneak patched classes into Grails distributed jar file.

1. Create a normal Grails project and add patched source based on same package structure of Grails source code. Compile it to get the classes.

2. Recreate the Grails jar file which contains classes you want to patch. Replace same jar file at $GRAILS_HOME/dist/. Note, Grails cache those jars under $USER_HOME/.ivy2/cache/org.grails. So make sure delete the cached jar file.


Just a side note: Thread.dumpStack() is quite useful to see stack trace.