Being an agile software development company we use a continuous integration (CI) server like Hudson.
For our grails projects we wrote a simple ant target -call-grails to call the batch or the shell scripts:
<condition property="grails" value="${grails.home}/bin/grails.bat"> <os family="windows"/> </condition> <property name="grails" value="${grails.home}/bin/grails"/> <target name="-call-grails"> <chmod file="${grails}" perm="u+x"/> <exec dir="${basedir}" executable="${grails}" failonerror="true"> <arg value="${grails.task}"/> <arg value="${grails.file.path}"/> <env key="GRAILS_HOME" value="${grails.home}"/> </exec> </target>
Calling it is as easy as calling any ant target:
<target name="war" description="--> Creates a WAR of a Grails application"> <antcall target="-call-grails"> <param name="grails.task" value="war"/> <param name="grails.file.path" value="${target.directory}/${artifact.name}"/> </antcall> </target>
One pitfall exists though, if your target takes no argument(s) after the task you have to use a different call:
<target name="-call-grails-without-filepath"> <chmod file="${grails}" perm="u+x"/> <exec dir="${basedir}" executable="${grails}" failonerror="true"> <arg value="${grails.task}"/> <env key="GRAILS_HOME" value="${grails.home}"/> </exec> </target>
We use the “Execute shell command” on Hudson to invoke grails directly with the gant scripts that i gives.. They are more programatically expressive, flexiable and require less maintenance than invoking Ant..
You need grails on the path of Hudson, cd in and then its like running from developer command line.
Try it!
There is a hudson plugin that allows you to invoke gant tasks as build steps as well:
http://hudson.gotdns.com/wiki/display/HUDSON/Gant+Plugin