我是Gradle的新手。我有一个ANT构建项目,我使用build.gradle中的ant.importBuild导入Gradle。
这是我正在使用的一个简单的ant build.xml -
<project>
<target name="hello">
<echo>Hello, from Ant</echo>
</target>
</project>
普通导入工作正常,我可以运行hello目标。这是我的build.gradle的内容(有效) -
ant.importBuild('build.xml')
但是,在导入时,我想重命名目标,以便它们不会与我的Gradle项目中的其他任务发生冲突。所以,当我导入build.xml时这样 -
ant.importBuild('build.xml') { antTargetName ->
'a' + antTargetName
}
它因此错误而失败 -
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Git\appsec\archutil\gradle_migration\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating root project 'gradle_migration'.
> Problem: failed to create task or type importBuild
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
我一定是在做一些愚蠢的错事。它是什么?谢谢!!
答案 0 :(得分:1)
尝试更新的Gradle。我可以用2.0而不是2.4来复制。我认为可以在Gradle 2.2中添加覆盖蚂蚁目标名称的功能。