ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: Setting properties depending on the os
Date Thu, 17 May 2001 23:31:11 GMT
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${}" value="true"/>

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

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


--- Dave Townsend <> 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="${}"/>
> </target>
> <target name="Linux">
> 	<property name="homedir" value="${}"/>
> </target>
> <target name="Windows">
> 	<property name="homedir" value="${}"/>
> </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 ${} in as a dependency to the basic target, but it
> seems that properties cant be used there.
> Dave Townsend <>
> "Vital papers will demonstrate their vitality by spontaneously moving
> from
> where you left them to where you can't find them."


Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

View raw message