3

我到底怎么能在 gradle 中做到这一点:例如。想HTTPBuilder在任务中使用。

构建.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??
}
4

1 回答 1

4

要直接在构建脚本中使用类,您需要在 buildscript { } 闭包中将依赖项声明为脚本类路径的一部分。例如:

buildscript {
   repositories {
       mavenRepo urls: "http://repository.codehaus.org"
   }
   dependencies {
      classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0'
   }
}
于 2010-09-21T05:50:56.263 回答