如何从Gradle 0.6引用类路径

tro*_*nda 4 groovy build gradle

我有一个使用Gradle作为构建工具的项目,我必须使用Ant Java任务.此任务中的一个子元素是对类路径的引用,我想使用refid.构建脚本使用Gradle的WAR插件.由于编译任务没有任何问题,我知道类路径设置正确:

dependencies {
  compile 'commons-beanutils:commons-beanutils:1.8.0'
  compile group: 'commons-lang', name: 'commons-lang', version: '2.4'
  ...
}

不,我想在我的Gradle构建脚本中引用此类路径.

我尝试过以下方法:

使用classpathId(内置?)搜索Gradle邮件列表并找到一个建议:

project.dependencies.antpath('compile')

这会导致错误.还尝试了一些这方面的变种,但到目前为止没有运气.任何建议表示赞赏.

tro*_*nda 10

以下将访问配置的依赖项:

configurations.compile.asPath

如果您已定义自己的配置,也可以使用它:

configurations {
    gwtCompile
}
....
ant.java(classname:'com.google.gwt.dev.Compiler', fork:'true', failOnError: 'true') {
    jvmarg(value: '-Xmx184M')
    arg(line: '-war ' + gwtBuildDir)
    arg(value: 'com.yoobits.ocs.WebApp')
    classpath {
        pathElement(location: srcRootName + '/' + srcDirNames[0])
        pathElement(path: configurations.compile.asPath)
        pathElement(path: configurations.gwtCompile.asPath)
    }
}

在上面的例子中,我访问了编译路径和我自己的配置,这只是在构建期间的特殊阶段 - 使用GWT编译器进行编译时感兴趣.