Playing with maven release plugin

Using maven release plugin can save you a lot of time, especially if you still manually mange your project versioning. But sometimes it can be pain in the “back”. Simple scenario that occurred at least few times in some of my maven projects:

  1. Project contains at least two separate modules (A & B)
  2. One of this modules (A) is dependant on the other module (B)
  3. While trying to prepare a release (release:prepare) you get missing artefact error which points at second module (B) “Brute force” solution is launching clean install process just after getting missing artefact error and after that resume release prepare process (release:prepare). But since maven release plugin main purpose was cutting down unnecessary manual work like this – solution should be little bit subtle. For example you can change a little bit plugin configuration:
org.apache.maven.plugins
    maven-release-plugin
    2.0

        clean install


Lot of other helpful configuration properties exists, be sure to check

http://maven.apache.org/plugins/maven-release-plugin/prepare-mojo.html

You May Also Like

Grails render as JSON catch

One of a reasons your controller doesn't render a proper response in JSON format might be wrong package name that you use. It is easy to overlook. Import are on top of a file, you look at your code and everything seems to be fine. Except response is still not in JSON format.

Consider this simple controller:

class RestJsonCatchController {
def grailsJson() {
render([first: 'foo', second: 5] as grails.converters.JSON)
}

def netSfJson() {
render([first: 'foo', second: 5] as net.sf.json.JSON)
}
}

And now, with finger crossed... We have a winner!

$ curl localhost:8080/example/restJsonCatch/grailsJson
{"first":"foo","second":5}
$ curl localhost:8080/example/restJsonCatch/netSfJson
{first=foo, second=5}

As you can see only grails.converters.JSON converts your response to JSON format. There is no such converter for net.sf.json.JSON, so Grails has no converter to apply and it renders Map normally.

Conclusion: always carefully look at your imports if you're working with JSON in Grails!

Edit: Burt suggested that this is a bug. I've submitted JIRA issue here: GRAILS-9622 render as class that is not a codec should throw exception