You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kurien Mathew <ku...@envivio.com> on 2001/08/20 20:58:40 UTC

Setting a property based on the OS

Is it possible to set a property based on the OS?

For eg consider the following folder setup

redist
 |- win32
 |- mac
 |- linux

I would like to set a property ${redistdir} based on the OS and then use it
to copy redistributable files from the relevant folder.

If there is a better way to accomplish this. Please let me know.





Re: Setting a property based on the OS

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 21 Aug 2001, T. Master <tm...@iknowledgeinc.com> wrote:

> I've not seen the docs for the <condition> task, so was wondering
> how ot integrate its use with a <target>

<condition> is just a task like <available> (a more general form of it
actually).  

You can find the docs in the 1.4beta distribution as well as here:
<http://cvs.apache.org/viewcvs/~checkout~/jakarta-ant/docs/manual/CoreTasks/condition.html?rev=1.1&content-type=text/html>.

Stefan

Re: Setting a property based on the OS

Posted by T Master <tm...@iknowledgeinc.com>.
I've not seen the docs for the <condition> task, so was wondering how ot
integrate its use with a <target>
That's all.

----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>
To: <an...@jakarta.apache.org>
Sent: Monday, August 20, 2001 11:08 PM
Subject: Re: Setting a property based on the OS


> On Mon, 20 Aug 2001, T. Master <tm...@iknowledgeinc.com> wrote:
>
> > How would this then be used in a target?
>
> <conditon>? Like any other task.  Or do you mean the property? Like
> any other property.
>
> Stefan
>


Re: Setting a property based on the OS

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 20 Aug 2001, T. Master <tm...@iknowledgeinc.com> wrote:

> How would this then be used in a target?

<conditon>? Like any other task.  Or do you mean the property? Like
any other property.

Stefan

Re: Setting a property based on the OS

Posted by T Master <tm...@iknowledgeinc.com>.
How would this then be used in a target?

----- Original Message ----- 
From: "Stefan Bodewig" <bo...@apache.org>
To: <an...@jakarta.apache.org>
Sent: Monday, August 20, 2001 1:04 PM
Subject: Re: Setting a property based on the OS


> On Mon, 20 Aug 2001, Kurien Mathew <ku...@envivio.com> wrote:
> 
> > Is it possible to set a property based on the OS?
> 
> > redist
> >  |- win32
> >  |- mac
> >  |- linux
> > 
> 
> Using 1.4beta
> 
> <condition property="redistdir" value="redist/win32">
>   <os family="windows" />
> </condition>
> <condition property="redistdir" value="redist/mac">
>   <os family="mac" />
> </condition>
> <condition property="redistdir" value="redist/linux">
>   <equals arg1="${os.name}" arg2="Linux" />
> </condition>
> 
> Stefan
> 


Re: Setting a property based on the OS

Posted by Erik Hatcher <er...@earthlink.net>.
Actually you can do something more automatic than having to manually set a
property.   You can define a property like this:

    <property name="is${os.name}" value="whatever"/>

And replace your 'if' statement below with things like:

    if="isWindows 2000"


----- Original Message -----
From: "Cornellious Mann" <co...@yahoo.com>
To: <an...@jakarta.apache.org>
Sent: Monday, August 20, 2001 12:22 PM
Subject: Re: Setting a property based on the OS


> Another possible way to do this in version 1.3 would
> be to set up a different property for each OS, and
> then test for the existence of that property.
>
> Your command line would read...
>
> ... -Dlinux=true ...
> or
> ... -Dwindows=true ...
>
> The value after the property ("true") would only exist
> for documentation and wouldn't be used.
>
> In Ant you would then code...
>
> <target name="processLinux" if="linux">
>     ...
> </target>
>
> <target name="processWindows" if="windows">
>     ...
> </target>
>
> <target name="processOS">
>     <antcall target="processLinux"/>
>     <antcall target="processWindows"/>
> </target>
>
>
> --- Stefan Bodewig <bo...@apache.org> wrote:
> > On Mon, 20 Aug 2001, Kurien Mathew
> > <ku...@envivio.com> wrote:
> >
> > > Is it possible to set a property based on the OS?
> >
> > > redist
> > >  |- win32
> > >  |- mac
> > >  |- linux
> > >
> >
> > Using 1.4beta
> >
> > <condition property="redistdir"
> > value="redist/win32">
> >   <os family="windows" />
> > </condition>
> > <condition property="redistdir" value="redist/mac">
> >   <os family="mac" />
> > </condition>
> > <condition property="redistdir"
> > value="redist/linux">
> >   <equals arg1="${os.name}" arg2="Linux" />
> > </condition>
> >
> > Stefan
>
>
> =====
> Regards,
> Cornellious Mann
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo! Messenger
> http://phonecard.yahoo.com/


Re: Setting a property based on the OS

Posted by Cornellious Mann <co...@yahoo.com>.
Another possible way to do this in version 1.3 would
be to set up a different property for each OS, and
then test for the existence of that property.

Your command line would read...

... -Dlinux=true ...
or
... -Dwindows=true ...

The value after the property ("true") would only exist
for documentation and wouldn't be used.

In Ant you would then code...

<target name="processLinux" if="linux">
    ...
</target>

<target name="processWindows" if="windows">
    ...
</target>

<target name="processOS">
    <antcall target="processLinux"/>
    <antcall target="processWindows"/>
</target>


--- Stefan Bodewig <bo...@apache.org> wrote:
> On Mon, 20 Aug 2001, Kurien Mathew
> <ku...@envivio.com> wrote:
> 
> > Is it possible to set a property based on the OS?
> 
> > redist
> >  |- win32
> >  |- mac
> >  |- linux
> > 
> 
> Using 1.4beta
> 
> <condition property="redistdir"
> value="redist/win32">
>   <os family="windows" />
> </condition>
> <condition property="redistdir" value="redist/mac">
>   <os family="mac" />
> </condition>
> <condition property="redistdir"
> value="redist/linux">
>   <equals arg1="${os.name}" arg2="Linux" />
> </condition>
> 
> Stefan


=====
Regards,
Cornellious Mann

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: Setting a property based on the OS

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 20 Aug 2001, Kurien Mathew <ku...@envivio.com> wrote:

> Is it possible to set a property based on the OS?

> redist
>  |- win32
>  |- mac
>  |- linux
> 

Using 1.4beta

<condition property="redistdir" value="redist/win32">
  <os family="windows" />
</condition>
<condition property="redistdir" value="redist/mac">
  <os family="mac" />
</condition>
<condition property="redistdir" value="redist/linux">
  <equals arg1="${os.name}" arg2="Linux" />
</condition>

Stefan