【发布时间】:2016-09-19 16:29:55
【问题描述】:
我使用基于ant脚本的软件(Drops)。
我尝试动态生成要复制的文件的目标路径。为此,我执行了一个 linux 命令行。
在我的应用程序中,我有以下属性:
- environment.props.environment_name=recette
- application.props.target.gmao=/opt/${environment.props.environment_name}/gmao-ws
我希望 Ant 在运行时将 ${environment.props.environment_name} 替换为其值。但事实并非如此。
这是我编写的 Ant 脚本:
<project xmlns:drops="antlib:com.arcadsoftware.mmk.anttasks" name="deployJar" basedir="." default="main">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<taskdef resource="com/dropssoftware/drops/ant/antlib.xml"/>
<loadDropsContext/>
<target name="main">
<!-- get the value of the property "application.props.target.gmao" -->
<propertycopy name="target.dir" from="application.props.target.gmao"/>
<!-- I expect this to print target.dir=/opt/recette/gmao-ws but it print target.dir=/opt/${environment.props.environment_name}/gmao-ws -->
<echoproperties />
<!-- Supposed to copy from /opt/drops/storage/afile.jar to /opt/recette/gmao-ws but the property "target.dir" is wrong -->
<exec executable="sudo">
<arg value="/bin/cp"/>
<arg value="${param.artifacts.root}/${param.jar.root}"/>
<arg value="${target.dir}"/>
</exec>
</target>
</project>
有了这个输入:
- param.env=gmao
- param.artifacts.root=/opt/drops/storage/
它应该从 artifacts 目录复制一个文件到 /opt/recette/gmao-ws 目录。但 Ant 试图将其复制到 /opt/${environment.props.environment_name}/gmao-ws。
我不明白为什么 Ant 不将 ${environment.props.environment_name} 替换为其值。
是否可以强制 Ant 用它的值替换替换变量?
【问题讨论】:
标签: ant ant-contrib