Pither.com / Simon
Development, systems administration, parenting and business

Upgrading a Maven Grails project from 1.1 to 1.1.1

Grails 1.1.1 has been out for a while now. For those people who use grails directly the upgrade path is pretty simple (download, install, run "grails upgrade"). However for those of us who haven decided to build our projects via maven, the path seems to be much less clear.

There is a large mailing list thread or a more succinct comment that do cover what is needed to compile with 1.1.1 for most projects.

Here is that comment repeated in "svn diff" form for the project I've just upgraded:

Index: pom.xml
--- pom.xml (revision 95)
+++ pom.xml (working copy)
@@ -10,12 +10,12 @@
-      <version>1.1</version>
+      <version>1.1.1</version>
-      <version>1.1</version>
+      <version>1.1.1</version>

     <!-- Grails defaults to OSCache for the second-level Hibernate cache. -->
@@ -58,6 +58,14 @@
+    <!-- This is really a Grails 1.1.1 dependency, but it's not yet declared as such, so the work around is to include it here... -->
+    <dependency>
+      <groupId>org.tmatesoft.svnkit</groupId>
+      <artifactId>svnkit</artifactId>
+      <version></version>
+      <scope>runtime</scope>
+    </dependency>

@@ -99,7 +107,7 @@
-        <version>1.0</version>
+        <version>1.1-SNAPSHOT</version>
Index: application.properties
--- application.properties  (revision 97)
+++ application.properties  (working copy)
@@ -9,4 +9,4 @@

Unfortunately that's not the whole storey though, as there are still several files that live within your project tree that are really part of Grails, and have changed between 1.1 and 1.1.1. So you have to put your project through the "grails upgrade" process to pick them up.

In theory running mvn grails:exec -Dcommand="upgrade" should do the job. But it doesn't. It managed about half of the job and then fails with an error:

Embedded error: java.lang.reflect.InvocationTargetException
/home/simon/build/cosalt/trunk/webapp/null/src/war not found.

So the solution seems to require a download of Grails 1.1.1...

$ cd /tmp
$ wget http://grails.org/download/file?mirror=99
$ tar -xzf grails-bin-1.1.1.tar.gz
$ cd <your project dir>
$ GRAILS_HOME=/tmp/grails-1.1.1 /tmp/grails-1.1.1/bin/grails upgrade

<confirm the upgrade>

That will add and replace a few files within your project tree. To add the new ones to svn:

$ svn add ivysettings.xml ivy.xml webapp-test.launch

One of the files that gets replaced is .classpath, but it gets replaced with lots of things that really aren't suitable for a maven project, so:

$ svn revert .classpath

Commit it all and you should be fully upgraded to 1.1.1. I do hope the Grails developers improve this process a little in the future!

While upgraded, that still wasn't the whole story for this particular project as it also uses the quartz plugin which disagrees with Grails 1.1.1 (whether you use maven or not). There is an easy work around available though, assuming you don't want to run quartz jobs in your integration tests. Here's the change I needed in svn diff format again:

Index: grails-app/conf/QuartzConfig.groovy
--- grails-app/conf/QuartzConfig.groovy (revision 95)
+++ grails-app/conf/QuartzConfig.groovy (working copy)
@@ -1,6 +1,11 @@
 quartz {
-    autoStartup = true
+    if (Environment.current != Environment.TEST) {
+        autoStartup = true
+    }
+    else {
+        autoStartup = false
+    }
     jdbcStore = false

My project has gained a couple of warnings, but still passes it's tests and seems to work, in theory now with less bugs and 30% faster GSP rendering!

Add a comment