Friday, November 20, 2009

Grail Projects in Hudson

Here is a quick reference for adding a Grails project to Hudson. I'm assuming the webtest plugin is installed becuase there is no reason not to use it. It rocks. Also note that for integration into my existing maven build, I'm using the built-in Grails v1.1.1 maven integration. The project structure was created via the maven archetype:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate \
-DarchetypeGroupId=org.grails \
-DarchetypeArtifactId=grails-maven-archetype \
-DarchetypeVersion=1.1 \
-DgroupId=com.black -DartifactId=grails-project

With that, here is what works so far:

General sequence (these are also the steps for keeping a development team in synch):
  1. svn up
  2. grails upgrade --non-interactive
  3. mvn clean install -DnonInteractive=true

Notes:
  • Step 2 above: This upgrades the grails project to include all core grails plugins and also creates some important files under web-app/WEB-INF (applicationContext.xml, ...). We would rather run mvn grails:exec -Dcommand=upgrade -DnonInteractive, however, this fails with an error: Embedded error: java.lang.reflect.InvocationTargetException
    /home/black/dev/branches/parent/grails-project/null/src/war not found.
    Anybody have an idea on this?
  • Step 3 above: This step will upgrade all non-core plugins added/modified/removed since the last checkout. Since grails will ask the "are you sure" question, make sure in CI to add the non-interactive switch as above, which will have the effect of cheerfully answering "Y" to all of grails questions.

Problems you may run into:

  1. As part of a big maven multiproject build, grails may consume enough memory to produce an out of memory error.
    • Fix: Set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=150m


  2. Adding new grails plugins to the build will freeze the CI build due to the "are you sure" prompt. The same will happen when removing a grails plugin.
    • Fix: Add the non-interactive switch to the build (mvn -DnonInteractive=true or grails --non-interactive)


  3. Webtest launches a window during the test run that needs a display, so CI may need to run the webtests headless.
    • Fix: Add non-interactive switch to the build (mvn -DnonInteractive=true or grails --non-interactive)


  4. Webtest starts the jetty server on port 8080 by default which may clash with other services on your CI box using that port.
    • Fix: Use the switch mvn -Dserver.port=8183. Note: The webtest.properties file property wt.config.port seems to be used if the code under test were already hosted on another running server besides the provided jetty.


  5. A maven multiproject build that includes a grails project with webtests will look for /test/webtest/conf/webtest.properties in the wrong directory. That is, it will not look in ${basedir}, but always in the root project where you invoked maven to start with.
    • Workaround: Create a hudson job that only builds the grails war/webtest project. Create a downstream dependency on your main CI hudson job to trigger this one to build.

    • Fix: ?? Anyone have an answer for this one?



I hope this helps. For the few items above that have lingering questions, I would be interested in hearing if you have solved these. Let me know.