Showing posts with label grails. Show all posts
Showing posts with label grails. Show all posts

Sunday, February 26, 2012

Gradle Grails Plugin for Grails 2.0.x

I love the Grails Framework but sometimes I prefer to build my Grails projects using Gradle. I am just happier that way.

I have just started upgrading one of our projects to Grails 2.0.x and thought I would share what our build.gradle looks like.

Full build script can be found on Github. Enjoy!


Thursday, February 19, 2009

Oracle XMLParser and Grails - Lessons learnt

A few days ago I was trying to integrate the work of a colleague into a light Grails application I am currently maintaining but experienced classpath hell with Oracle's XMLParser V2. A better description of the problem can be found in the JIRA for the Grails project here.

The steps prescribed didn't seem to work so I thought I'd do some digging again. I'll disappoint you by telling you that the JIRA issue remains unresolved and I was only able to come up with a work around. I looked into the script for RunWar and it would appear that for some reason, Grails defaults to a non-validating parser before kicking off Jetty.

The following lines in the RunWar.groovy script for Grails-1.0.3 is telling:

System.setProperty('org.mortbay.xml.XmlParser.NotValidating','true')


This single line of code ensures that you use a non-validating parser to start up Jetty and parse your application's web.xml. Maybe if there was another means for configuring your xml parsing for Jetty in Grails it would solve the problem.

I also tried other hacky things like replacing the SAXParserFactory as suggested here but that didn't work. In the meantime I have had to make do with refactoring my classes so that they don't exchange data of xmlType directly with the database. For now Strings/Clobs will suffice until I can find an unobtrusive way of starting Jetty from Grails that will condone Oracle's XmlParser on the classpath.

Your suggestions are very welcome.

Friday, January 30, 2009

Grails Testing Tip

I had always wondered how to run individual types of tests in Grails. In order words I wanted to be able to run unit tests only or integration tests only. I did some digging in the TestApp.groovy script that ships with Grails and found that all you needed to do was specify it as an option on the command line.

grails test-app -unit
or
grails test-app -integration

This works as far as I know with Grails 1.0.3 not sure of 1.0.4 and 1.1-betas but I assume they won't be decommissioning this feature in a while since it is important. 
Never really got individual tests working though, as I have been unable to find anywhere that says how to run an individual test class.

Pointers to this will be appreciated.

In the coming days, I'll say something about mocking in Groovy using the 'as' feature.