Wednesday, June 27, 2012

How do I set a new version for my existing Grails application?


I have been working with Grails lately for a new web project. So far it has been hard, but a lot of fun. I am new to Groovy as well. But I do have experience with Spring and Hibernate, which the application framework is built on top of. I found a JIRA issue which matched an error I was seeing in my code.

I am using Spring Source Tool Suite (STS) to develop the application and, by default, new projects are set with a version of Grails preinstalled by the Grails plugin, in my case it was at version 2.0.3. The fix I need is in version 2.0.4. This brought me to a question: How do I switch to a newer version of Grails or backport a fix to my version? The Grails documentation is quite extensive but I did not find a command to do this. This command:
grails set-version 2.0.4

| Loading Grails 2.0.3
| Configuring classpath.
| Environment set to development.....
| Application version updated to 2.0.4

Only sets your application's declared version, not the version of grails used to build and run your application.

Under the covers, this command is simply modifying the application.properties file and setting the property named app.version to the value you specify.

This same file has a property named app.grails.version, my app has this set to:
app.grails.version=2.0.3
Changing that value to 2.0.4, will not change what version of Grails you application is built with in STS, but I changed the value to 2.0.4 anyway. To get on 2.0.4 and resolve my issue I needed to first download the version of Grails I want to switch to. Extract the download to a file location on my system. Then in STS, I added the new version to the Grails plugin and set it as the default version. This is done using Window | Preferences | Groovy | Grails | Add. Finally in STS, use the grails command prompt (ctrl+alt+shift+g) to run

grails clean
| Loading Grails 2.0.4
| Configuring classpath.
| Environment set to development.....
| Application cleaned.

I am now  able to run my  application, all the classes are compiled with the new Grails version and the project is upgraded.


| Loading Grails 2.0.4
| Configuring classpath.
| Environment set to test.....
| Compiling 1 source files.....
| Compiling 50 source files.
| Running 2 unit tests... 1 of 2
| Running 2 unit tests... 2 of 2
| Completed 2 unit tests, 0 failed in 13013ms
| Tests PASSED - view reports in target\test-reports
I am still not sure about the process to backport JIRA fixes as patches to an older version, but this solution is sufficient for me for the current state of my project. Maybe I will post a question to stackoverflow about porting fixes to older versions.


If you are starting a Grails project, be sure to bookmark the Groovy, Grails, Spring, Hibernate, forums and  JIRA sites. Be aware of what versions of these technologies your project is running so you can intelligently find and resolve problems.


No comments:

About Me

My photo
Lead Java Developer Husband and Father

Tags