You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by JG <z2...@gmail.com> on 2006/02/24 00:00:41 UTC
Detecting what OS you are running...
Hi,
I am writing an ANT config script that is to be used on multiple platforms
(Windows XP, Mac, Fedora) and I have a target that I want to run a certain
way for Windows XP and another way for other OS's.
Is there a way to make a target run only for a given OS?
thanks,
joe
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Detecting what OS you are running...
Posted by Tommy Nordgren <to...@chello.se>.
On 24 feb 2006, at 00.00, JG wrote:
> Hi,
>
> I am writing an ANT config script that is to be used on multiple
> platforms
> (Windows XP, Mac, Fedora) and I have a target that I want to run a
> certain
> way for Windows XP and another way for other OS's.
>
> Is there a way to make a target run only for a given OS?
>
> thanks,
> joe
>
<condition property="isDarwin">
<equals arg1="Mac OS X" arg2="${os.name}" />
</condition>
<target name="darwinTarget" if="isDarwin">
...
</target>
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
tommy.nordgren@chello.se
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Detecting what OS you are running...
Posted by "Ivan \"Rambius\" Ivanov" <ra...@yahoo.com>.
Hello,
here are some hints.
1) You can use os.name property to find the OS you are
running on.
2) If you want to execute a native OS command only on
the OS that supports it you can use <exec> task with
os attribute. See [1] for more details.
3) If you want to run different targets depending on
the os you can use <condition> with nested <os>
element [2]:
<condition property="isWindows">
<os family="windows"/>
</condition>
<condition property="isUnix">
<os family="unix"/>
</condition>
<target name="execute"
depends="executeUnix,executeWindows"/>
<target name="executeUnix" if="isUnix">
<!-- Do Unix stuff -->
</target>
<target name="executeWindows" if="isWindows">
<!-- Do Windows stuff -->
</target>
Regards
Ivan
[1]http://ant.apache.org/manual/CoreTasks/exec.html
[2]http://ant.apache.org/manual/CoreTasks/conditions.html
--- JG <z2...@gmail.com> wrote:
> Hi,
>
> I am writing an ANT config script that is to be used
> on multiple platforms
> (Windows XP, Mac, Fedora) and I have a target that I
> want to run a certain
> way for Windows XP and another way for other OS's.
>
> Is there a way to make a target run only for a given
> OS?
>
> thanks,
> joe
>
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org