ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julian M. Savage" <>
Subject Re: Eager evaluation of properties
Date Fri, 29 Sep 2000 09:00:19 GMT
I have a similar need, but I took a slightly different approach. I'm not
sure whether the following works on 1.1 or not - I'm using 1.2alpha3 or

It looks like you might be defining different port numbers for different
developers on the same machine. That's my need, in any case.

I wrote a perl script which creates a simple properties file for each user
in their home directory, with slightly different values for each user, and
once the initial version is created, they can modify it to suit themselves.
Of course, new users will have to create their own configuration files (or
run the script), but then, at least you won't have to change your build file
every time a new developer joins your project.

In addition I made it so that the user can override the name of the property
file itself, so that if they want to make different builds in different
directories with slightly different options, they can do it quickly by
writing a couple of different property files.

<project name="myproject" default="compile" basedir=".">
    <property name="pref.file" value="${user.home}/.ant.preferences"/>
    <property file="${pref.file}"/>

    <!-- Start defining project properties. -->


ant -Dpref.file=ant-set1 dist
ant -Dpref.file=ant-set2 dist


----- Original Message -----
From: "Alex Smith" <>
To: <>
Sent: Friday, September 29, 2000 7:37 AM
Subject: Eager evaluation of properties

> Hello,
> I tried looking in the archives ( except that I couldn't
> them :)
> I am trying to substitute a value twice where the second substitution is
> based on the results of the first. This amounts to a recursive evaluation
> and since I can't do this with tokens, I am trying a hack with properties.
> It almost works except that I am being foiled by properties-evaluate-first
> mechanism, even if I define a property after my first substitution that
> generates the property file which contains the desired properties
> thereafter.
> Concrete example: I have a file that looks like this
> @myProperty.baz@=30
> where 'foo', 'bar' and 'baz' are users on my box. I have another file that
> looks like this
> targetProperty=@myProperty@
> and I want @myProperty@ to be replaced with '10' if I am user 'foo'. To
> end I copy the first file to a temporary location, substituting all tokens
> that match with the string 'targetProperty'. Then I
> reference this newly built property file with <property file="..."> and
> the second file while substituting @myProperty@ with ${myProperty}. The
> step doesn't work because ${myProperty} is empty since the property task
> read the file in before it was created...even though <property file="...">
> is defined after the task that created the file referenced therein. (I
> trying explicit dependency instead of defining one after another in the
> task).
> Help? I am running Ant 1.1
> Thanks,
> Alex
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at
> Share information about yourself, create your own public profile at

View raw message