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

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

不,我想在我的 Gradle 构建脚本中引用这个类路径。

我尝试过以下方法:

使用ClassPathId(内置?)搜索了Gradle MailingLists并找到了一个建议:

project.dependencies.antpath('compile')

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

有帮助吗?

解决方案

下面将访问配置depedencies:

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编译器编译

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top