Dependencies 梯度任务依赖关系

Dependencies 梯度任务依赖关系,dependencies,task,gradle,Dependencies,Task,Gradle,在gradle中我到底该怎么做:例如,想在任务中使用HTTPBuilder 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 s

在gradle中我到底该怎么做:例如,想在任务中使用
HTTPBuilder

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??
}
存储库{
mavenRepo URL:“http://repository.codehaus.org"
}
配置{
测试配置
}
依赖关系{
testConfig'org.codehaus.groovy.modules.httpbuilder:httpbuilder:0.5.0'
}

task sometask使用shttpbuilder(dependsOn:configurations.testConfig)要在构建脚本中直接使用类,需要在构建脚本{}闭包中将依赖项声明为脚本类路径的一部分。例如:

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

是的,谢谢!经过一段时间后,终于在文档中找到了。我还将数据库驱动程序放在同一个buildscript闭包中,但类装入器似乎找不到它们?还有其他窍门吗?啊,刚刚在这里找到你的帖子,亚当,我想再次感谢;)