Thursday, April 8, 2010

Grails tips: using custom Ivy repositories

Starting from Grails 1.2.x, Ivy has been chosen as the default dependency resolution mechanism for libraries; however, the official user guide doesn't explain very well how to configure a custom repository.

The BuildConfig.groovy
Following the guide, the BuildConfig.groovy is the place where both dependencies and resolvers are configured. It is placed on [app-name]/grails-app/conf of every grails application.

We need to configure Grails to use the our custom repository by adding an appropriate dependency resolver; note that you can add as many as you want simply by configuring them and then calling the resolver method, like the following example:


That's all! Now you can declare your dependencies on the dependencies closure.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. If I just paste what you have into my BuildConfig.groovy I get the error:


    groovy.lang.MissingMethodException: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.resolver() is applicable for argument types: (groovy.util.ConfigObject) values: [[:]]
    Possible solutions: getOwner()
    at BuildConfig.run(BuildConfig.groovy:14)
    at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:646)
    at grails.util.BuildSettings$loadConfig.callCurrent(Unknown Source)
    at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:623)
    WARNING: There was an error loading the BuildConfig: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.resolver() is applicable for argument types: (groovy.util.ConfigObject) values: [[:]]
    Possible solutions: getOwner()

    I'm using Grails 1.3.4

    ReplyDelete
  3. Brian wondering if you figured out that problem? I am seeing the exact same thing on grails 1.3.7

    ReplyDelete