Monday, November 10, 2014

grails.gsp.enable.reload vs disable.auto.recompile in grails 1.3.7

Needed to make some GUI changes to a project that's developed based on grails 1.3.7.

In grails 2.* , if you edit a gsp file, it'll be automatically compiled in a few seconds, and if you refresh, you'd be able to see the changes in your GUI. But for some reason, it didn't seem to work in the my applications that's based on 1.3.7.

After some investigation, I found that I just needed to add the system property "-Dgrails.gsp.enable.reload=true" to the grails run-app. Then update the gsps and do a refresh of the web page. Unlike grails 2.*, there's nothing in the grails run-app log that indicates the changes to the gsp files have been picked up, and this got me stuck for a while, because I was expecting to see some change in the logs (Maybe the missing of the logs was due to my log4j setting).

The "-Ddisable.auto.recompile" property is to control the auto recompile of the java and groovy classes. And it's accomplished in grails via the following -

        ant.groovyc(destdir:classesDirPath,
                    classpathref:classpathId,
                    encoding:"UTF-8",
                    verbose: grailsSettings.verboseCompile,
                    listfiles: grailsSettings.verboseCompile,
                    excludes: '**/package-info.java') {
            src(path:"${grailsSettings.sourceDir}/groovy")
            src(path:"${basedir}/grails-app/domain")
            src(path:"${basedir}/grails-app/utils")
            src(path:"${grailsSettings.sourceDir}/java")
            javac(classpathref:classpathId, debug:"yes")