views:

36

answers:

1

How on earth can I do this in gradle: eg. want to use HTTPBuilder in a task.

build.gradle:

repositories {
 mavenRepo urls: "http://repository.codehaus.org"
}
configurations {
 testConfig
}
dependencies {
 testConfig 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'
}

task someTaskThatUsesHTTPBuilder (dependsOn: configurations.testConfig) << {
     new HTTPBuilder()// <--this cannot be resolved/found??
}
A: 

To use a class directly in your build script, you need to declare the dependency as part of the script's classpath in the buildscript { } closure. For example:

buildscript {
   repositories {
       mavenRepo urls: "http://repository.codehaus.org"
   }
   dependencies {
      classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'
   }
}
Adam Murdoch
Yes - thanks! Finally found that in the documentation after a while. I also put my database drivers in the same buildscript closure, but the class loader can't seem to find them? Is there another trick to use?
jhall
Ah just found your post here Adam, thanks again i guess ;) http://www.mail-archive.com/[email protected]/msg02450.html
jhall