gpt4 book ai didi

gradle - 如何将参数从gradle传递到ant?

转载 作者:行者123 更新时间:2023-12-03 03:58:32 26 4
gpt4 key购买 nike

我有以下两个文件:

build.gradle:

ant.importBuild 'build.xml'

build.xml:
<project>
<target name="hello">
<echo>Hello, I'm ${testVar}</echo>
</target>
</project>

如何将gradt中的 testVar变量传递给ant以触发ant构建?
gradle -PtestVar=John hello输出
> Task :hello
[ant:echo] Hello, I'm ${testVar}

这意味着 testVar没有分配值。

我可以使用 testVar命令直接将 ant -DtestVar=John -buildfile build.xml hello变量传递给ant。

我如何使用gradle做同样的事情?

最佳答案

我发现将build.gradle文件更改为

ant.importBuild 'build.xml'
ant.properties['testVar'] = testVar

解决了问题。

修改后, gradle -PtestVar=Ken hello生成
> Task :hello
[ant:echo] Hello, I'm Ken

这是我想要的结果。

关于gradle - 如何将参数从gradle传递到ant?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51644803/

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