ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Cross-platform properties?
Date Thu, 10 May 2001 06:25:45 GMT
Mark Jaffe <mjaffe@eturn.com> wrote:

> I am working with a project that needs to work on both unix and
> NT. IUs there an easy way to set properties that will know their
> platform?

Yes, use property tasks inside of targets that will only be executed
on the appropriate OS.  Using a very Unix simple heuristic (everything
that doesn't have a C:\config.sys is Unix, everything that does is
Windows) this would look like

<target name="os-check">
  <available property="win" file="C:\config.sys" />
</target>

<target name="set-for-windows" depends="os-check" if="win">
  <property name="home" value="c:\winnt\profiles\user" />
</target>

<target name="set-for-unix" depends="os-check" unless="win">
  <property name="home" value="/home/user" />
</target>

<target name="set" depends="set-for-windows,set-for-unix" />

Stefan

PS: You are not trying to reinvent ${user.home}, are you?

Mime
View raw message