Dependency management in Grails 1.2

March 23rd, 2010 by

Sometimes I get the impression that there are many Maven haters in the Groovy/Grails community – now with version 1.2 of the Grails framework they are able to abandon the evil satanic Grails Maven Plugin and embrace the neverending joys of a slim, nice, sexy dependency resolution dsl .. here we go .. lets define some dependencies wheee …

  1. Our dependency configuration is defined in grails-app/config/BuildConfig.groovy as a property named grails.project.dependency.resolution:
    grails.project.dependency.resolution = {
    // here will be some dependencies
  2. The default config look like this:
    grails.project.dependency.resolution = {
     inherits "global" // inherit Grails' default dependencies
     log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
     repositories {
     // uncomment the below to enable remote dependency resolution
     // from public Maven repositories
     //mavenRepo ""
     //mavenRepo ""
     //mavenRepo ""
     //mavenRepo "
     dependencies {
     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
     // runtime 'com.mysql:mysql-connector-java:5.1.5'
  3. There are currently five scopes supported: build, compile, runtime, test, provided
  4. If we want to add a dependency for a scope we can do this using the format <scope> <group>:<name>:<version> e.g.:
    compile 'com.mysql:mysql-connector-java:5.1.5'
  5. Adding other maven repositories is also possible e.g. for our internal maven repo:
    repositories {
       mavenRepo ""
  6. Often we have some additional linked lib folder we want to add to the repo list:
    repositories {
       flatDir name:'localRepo', dirs:'/var/somerepo'
  7. That’s not all folk! Authentication is another feature that can be configured using the shiny new dsl (example from the Grails docs):
    credentials {
       realm = ".."
       host = "localhost"
       username = "myuser"
       password = "mypass"
  8. Furthermore dependencies are inherited (done by inherit:global), we may define some exclusions here like that:
    inherits("global") {
       excludes "oscache", "ehcache"
  9. Another Feature is the dependency report command – after execution we get some dependency reports in our target/dependency-report directory:
    grails dependency-report


Grails Reference Docs:

Famous Graeme Rocher: “Grails dependancy resolution done right”

Grails Dependency Report Feature:


sounds nice, nuff’ said :)

Tags: , , , , , , ,

One Response to “Dependency management in Grails 1.2”

  1. hospedagem Says: