ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Townsend" <dave.towns...@bigfoot.com>
Subject RE: Setting properties depending on the os
Date Fri, 18 May 2001 07:49:44 GMT
Aah, I had forgotten about the if property of target. That should do the job
nicely. Cheers.

Oh, I did look at the env.HOME bit, but my windows box at least has no such
environment variable set.

Dave Townsend <dave.townsend@bigfoot.com>

"Duct tape is like the Force. It has a light side, a dark side, and it holds
the universe together." 
 

-----Original Message-----
From: Diane Holt [mailto:holtdl@yahoo.com]
Sent: 18 May 2001 00:31
To: ant-user@jakarta.apache.org
Subject: Re: Setting properties depending on the os


As an experiment, you could try using:

  <property environment="env"/>

then echo out what ${env.HOME} ends up being set to for your various
Windows boxes. If that doesn't cut it, and assuming all your Windows OSes
need that directory added, you could use what's been suggested before for
OS-specific targets:

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

  <target name="setHome" depends="setLinux, setWindows"/>
  <target name="setLinux" if="isLinux">
    <property name="homedir" value="${user.home}"/>
  </target>
  <target name="setWindows" unless="isLinux">
    <property name="homedir" value="${user.home}\My Documents"/>
  </target>

P.S. Yes, properties (or their overrides) set during the execution of an
<antcall> only stay around for the duration of that execution.

Diane

--- Dave Townsend <dave.townsend@bigfoot.com> wrote:
> I am trying to set some properties depending on what the os is. The main
> reason is that the user.home property does not properly reflect the
> users
> home directory (for files) on a windows machine. Instead you need the
> "My
> Documents" subdirectory of this. I attempted to do this as follows:
> 
> <target name="basic">
> 	<tstamp/>
> 	<antcall target="${os.name}"/>
> </target>
> 
> <target name="Linux">
> 	<property name="homedir" value="${os.name}"/>
> </target>
> 
> <target name="Windows">
> 	<property name="homedir" value="${os.name}"/>
> </target>
> 
> <target name="Windows 2000" depends="Windows">
> </target>
> 
> <target name="Windows 98" depends="Windows">
> </target>
> 
> <target name="Windows 95" depends="Windows">
> </target>
> 
> Unfortunatley from what I can tell, the property homedir no longer
> exists
> after the antcall task is complete. Is there any way to pass these back,
> or
> another way of doing what I am trying to achieve? The only other thought
> I
> had was to put ${os.name} in as a dependency to the basic target, but it
> seems that properties cant be used there.
> 
> Dave Townsend <dave.townsend@bigfoot.com>
> 
> "Vital papers will demonstrate their vitality by spontaneously moving
> from
> where you left them to where you can't find them."
> 
> 


=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Mime
View raw message