Sunday, March 27, 2011

Grails JAR dependencies with classifiers

Quick post on specifying Grails dependencies in BuildConfig.groovy.  The recommended way to suck in JAR dependencies in Grails is to use the dependencies DSL maintained in BuildConfig.groovy.  I had a need to bring down a dependency that has a classifier attribute on it.  Didn't really find anything definitive on how to do it, but it seemed like following a convention might do the trick.  Here's how I solved the issue:

repositories {
  grailsPlugins()
  grailsHome()
  grailsCentral()
  mavenCentral()
  ebr() // SpringSource Enterprise Bundle Repository
}
dependencies {
  runtime group:'net.sf.json-lib', name:'json-lib', version:'2.4', classifier:'jdk15'
}

5 comments:

  1. I tried this configuration but still get a not found error. Is there something missing?

    ReplyDelete
  2. I also have mavenCentral() and ebr() enabled for remote dependency resolution. I will edit my blog to include that information. I just put together a quick Grails app and included this dependency and I was able to get it to resolve.

    ReplyDelete
  3. Hello Christopher, I appreciate you taking a look. Unfortunately, those changes did not work either. I was able to get it working with the 2.2.3 version of the jar. I enabled all the default repo's in the buildConfig and added the ebr() repo too. None of the repo's could resolve the jar.

    I am not sure if this post has anything to do with the problem but I thought I would mention it.

    http://jira.grails.org/browse/GRAILS-6147

    ReplyDelete
  4. Chris,

    That's really odd. It worked fine for me on Grails 1.3.7. I believe that this whole dependency goes away in Groovy 1.8 with the inclusion of JsonSlurper and JsonParser as part of the core:

    http://groovy.329449.n5.nabble.com/Built-in-JSON-support-in-1-8-td3361699.html

    Sorry my solution did not work for you.

    -- chris --

    ReplyDelete