サンプル1-1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="sample" name="SampleJavaCodes">
<property name="value" value="hello" />
<target name="sample">
<condition property="is_hello" value="true">
<and>
<equals arg1="hello" arg2="${value}" />
</and>
</condition>
<echo>
${is_hello}
</echo>
</target>
</project>
出力結果
sample:
[echo] true
[echo]
BUILD SUCCESSFUL
Total time: 292 milliseconds
参考文献
http://minor.hatenablog.com/entry/2014/08/18/223719
サンプル1-2:OSで条件を変える
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="sample" name="SampleJavaCodes">
<target name="sample">
<condition property="os_name" value="This OS is a Windows!">
<os family="windows" />
</condition>
<condition property="os_name" value="This OS is a Linux!!">
<os family="unix" />
</condition>
<echo message="${os_name}" />
</target>
</project>
出力結果
sample:
[echo] This OS is a Windows!
BUILD SUCCESSFUL
Total time: 296 milliseconds
参考文献
http://www.coltware.com/2011/04/22/ant-condition-os/