gpt4 book ai didi

gradle - Gradle ant.importBuild在导入和重命名ant目标名称时失败

转载 作者:行者123 更新时间:2023-12-03 03:22:34 25 4
gpt4 key购买 nike

我是Gradle的新手。我有一个要在build.gradle中使用ant.importBuild导入到Gradle的ANT构建项目。

这是我正在使用的简单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.

我一定在做些愚蠢的错误。它是什么?谢谢 !!

最佳答案

尝试更新的Gradle。我可以用2.0而不是2.4进行复制。我认为可以在Gradle 2.2中添加覆盖 Ant 目标名称的功能。

关于gradle - Gradle ant.importBuild在导入和重命名ant目标名称时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31755366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com