build.xml - Conditional concatenation in Ant -
i have task like:
<target name="sometarget"> <concat destfile="somefile"> <string>somestring</string> <string>someotherstring</string> </concat> </target> <target name="someothertarget"> <antcall target="sometarget"> <param name="myparam" value="myvalue"></param> </antcall> <antcall target="sometarget"> </antcall> </target>
how can concatenate someotherstring
if myparam
supplied when calling sometarget
target?
without ant extensions, use conditional ant execution:
<project default="someothertarget"> <target name="sometarget" depends="-somestring,-someotherstring"/> <target name="-somestring" unless="myparam"> <concat destfile="somefile"> <string>somestring</string> </concat> </target> <target name="-someotherstring" if="myparam"> <concat destfile="someotherfile"> <string>somestring</string> <string>someotherstring</string> </concat> </target> <target name="someothertarget"> <antcall target="sometarget"> <param name="myparam" value="myvalue"></param> </antcall> <antcall target="sometarget"/> </target> </project>
if don't mind adding ant extensions project, check out ant-contrib's if task.
Comments
Post a Comment