<project name="Build" basedir="." default="clean">
<property name="default.build.type" value ="Release"/>
<target name="clean">
<echo>Value Buld is now ${PARAM_BUILD_TYPE} is set</echo>
<condition property="build.type" value="${PARAM_BUILD_TYPE}" else="${default.build.type}">
<isset property="PARAM_BUILD_TYPE"/>
</condition>
<echo>Value Buld is now ${PARAM_BUILD_TYPE} is set</echo>
<echo>Value Buld is now ${build.type} is set</echo>
</target>
</project>
In my Case DPARAM_BUILD_TYPE=Debug
if it is supplied than, I need to build for for Debug otherwise i need to go for building Release build.
I write like above condition it worked and i have tested as below it is working fine for me.
And property ${build.type}
we can pass this to other target or macrodef for processing which i am doing in my other ant macrodef.
D:\>ant -DPARAM_BUILD_TYPE=Debug
Buildfile: D:\build.xml
clean:
[echo] Value Buld is now Debug is set
[echo] Value Buld is now Debug is set
[echo] Value Buld is now Debug is set
main:
BUILD SUCCESSFUL
Total time: 0 seconds
D:\>ant
Buildfile: D:\build.xml
clean:
[echo] Value Buld is now ${PARAM_BUILD_TYPE} is set
[echo] Value Buld is now ${PARAM_BUILD_TYPE} is set
[echo] Value Buld is now Release is set
main:
BUILD SUCCESSFUL
Total time: 0 seconds
It work for me to implement condition so posted hope it will helpful.