Is it possible to set a property value in Ant property files (as opposed to build.xml
) in a conditional way? For example, if apache.root
property is set - the my_property
will be ${apache.root}/myapp
, /var/www/myapp
otherwise. If not, what would be the common practice - reusable build.xml
files?
Use the condition task:
<project name="demo" default="run">
<condition property="my_property" value="${apache.root}/myapp" else="/var/www/myapp">
<isset property="apache.root"/>
</condition>
<target name="run">
<echo message="my_property=${my_property}"/>
</target>
</project>