【发布时间】:2021-07-30 22:34:23
【问题描述】:
使用<ant antfile="..."> 调用任务时,如何从<ant ...> 调用中获取属性?我问是因为一个 Maven 插件 -- maven-antrun-plugin -- 使用这种表示法并声明建议使用具有这种表示法的外部文件。
要查看 Maven 项目中的代码,请单击此处:Retrieve value from external ant file for use in Maven project,或查看上游错误报告 here。
这是蚂蚁代码:
<project default="run-test">
<target name="run-test">
<!-- Call using antfile notation -->
<ant antfile="build.xml" target="antfile-task"/>
<echo level="info">Outside antfile: my.val: ${my.val}</echo>
</target>
<target name="antfile-task">
<property name="my.val" value="just some test value"/>
<echo level="info">Inside antfile: my.val: ${my.val}</echo>
</target>
</project>
输出:
Buildfile: build.xml
run-test:
antfile-task:
[echo] Inside antfile: my.val: just some test value
[echo] Outside antfile: my.val: ${my.val}
【问题讨论】: