How do I use properties in ants replace task?

2019-05-20 21:46发布

I need to replace a token with a property. That property has a path location set. I am not getting it as it is just replacing it with the $

<replace file="${APACHE_HOME}/conf/wc_server1.conf" >
  <replacetoken>@Install_Base_Directory@</replacetoken> 
<replacevalue>$InstallerBase</replacevalue>

标签: ant replace
2条回答
Fickle 薄情
2楼-- · 2019-05-20 22:19

You basically have two options:

<replace file="${APACHE_HOME}/conf/wc_server1.conf" >
  <replacetoken><![CDATA[@Install_Base_Directory@]]></replacetoken> 
  <replacevalue><![CDATA[$InstallerBase]]></replacevalue>
</replace>

or since it's only a single line replace, use:

<replace file="${APACHE_HOME}/conf/wc_server1.conf" 
  token="@Install_Base_Directory@"
  value="$InstallerBase" />
查看更多
家丑人穷心不美
3楼-- · 2019-05-20 22:27

When using Ant properties you must enclose the property name in curlies {...} to get at the value:

<replacevalue>${InstallerBase}</replacevalue>
查看更多
登录 后发表回答