Installing new version of Grails is easy. However it’s quite a pain to make it running on Cygwin. The problem is as follows:
Jdk 5 introduced “javaagent” as one of the JAVA_OPTS and it has been used in running Grails 2. Shell scripts convert $GRAILS_HOME in cygwin format for running grails. So for instance if $GRAILS_HOME is c:/grails, it becomes ‘/cygdrive/c’ in cygwin format. This makes
[bash]
AGENT_STRING=-"-javaagent:$GRAILS_HOME/lib/com.springsource.springloaded/springloaded-core/jars/springloaded-core-0.8.4.jar
[/bash]
to something like this:
[bash]
$ echo $AGENT_STRING
$ "-javaagent:/cygdrive/c/grails/lib/com.springsource.springloaded/springloaded-core/jars/springloaded-core-0.8.4.jar
[/bash]
which JRE doesn’t understand while executing ‘java’. It expects -javaagent value to be something like ‘c:/grails/lib/com.springsource.springloaded/springloaded-core/jars/springloaded-core-0.8.4.jar’.
To make it work, following changes need to be done in $GRAILS_HOME/bin/startGrails script:
Introduce a new variable something like GRAILS_HOME_FORWARD_SLASH before making any change to environment based $GRAILS_HOME.
[bash]
# For Cygwin, ensure paths are in UNIX format before anything is touched
GRAILS_HOME_FORWARD_SLASH=`echo $GRAILS_HOME|sed ‘s/[\]/\//g’`
[/bash]
Also change the way AGENT_STRING is defined as follows:
[bash]
AGENT_STRING="-javaagent:$GRAILS_HOME_FORWARD_SLASH/lib/com.springsource.springloaded/springloaded-core/jars/springloaded-core-0.8.4.jar -noverify -Dspringloaded=profile=grails"
[/bash]
This change lets you work with Grails 2 now on Cygwin
Leave a Reply