Reputation: 43077
I am pretty new in Ant (I came from Maven) and I have the following situation:
I need to execute 3 different actions depending on whether the system on which the Ant script is running is a Linux 64 bit, a Linux 32 bit or MacOS system.
Can I do this using Ant?
Upvotes: 1
Views: 183
Reputation: 7934
Yes.. You need to check the os family to determine linux or mac and on the linux machines also check os arch. These conditions will get you there.
<condition property="mac">
<os family="mac" />
</condition>
<condition property="unix.32">
<os family="unix" arch="x86" />
</condition>
<condition property="unix.64">
<os family="unix" arch="amd64" />
</condition>
So in ant you'd make targets that did whatever needed to be done on each, such as set properties that are unique to each architecture. These targets must conditionally run if the appropriate property is set for example: if=unix.64
in the target
element.
Then you'd want to ensure that all three targets are in the dependency tree, if the properties aren't set they'll not do anything.
Upvotes: 1