How do I use properties in ants replace task?

北城余情 提交于 2019-12-08 02:53:45

问题


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>

回答1:


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" />



回答2:


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

<replacevalue>${InstallerBase}</replacevalue>


来源:https://stackoverflow.com/questions/5216462/how-do-i-use-properties-in-ants-replace-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!