我怎么能在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??
}
答案 0 :(得分:4)
要在构建脚本中直接使用类,您需要将依赖项声明为buildscript {}闭包中脚本的类路径的一部分。例如:
buildscript {
repositories {
mavenRepo urls: "http://repository.codehaus.org"
}
dependencies {
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'
}
}