You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mark McKay <ma...@kitfox.com> on 2005/11/06 01:42:52 UTC

Specifiying user properties file

I'm trying to set up a situation where my users can specify a properties 
file where they can set properties specific to their machines.  I have 
my main build.xml file checked into my CVS repostiory, and a 
default.properties file that is also in the CVS repository.  I'd like 
the init task of my ant script to check if a file called user.properties 
exists, and if so to load properties from that file.  Otherwise, I'd 
like it to load properties fron the default.properties file.

Is there a way to do this (or something similar)?  Ant's lack of an <if> 
task makes setting up something like this difficult.

Mark McKay

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Specifiying user properties file

Posted by Ray Tayek <rt...@comcast.net>.
At 04:42 PM 11/5/2005, you wrote:
>I'm trying to set up a situation where my users can specify a 
>properties file where they can set properties specific to their machines. ...

properties are immutable so something like:

         <property environment="env"/>
         <property file="${user.home}/build.properties"/>
         <property file="build.properties"/>
         ...
         <property file="whereveryoulike.properties"/>

whoever defines a property first wins.

thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Specifiying user properties file

Posted by Jeffrey E Care <ca...@us.ibm.com>.
You can also use the fact that Ant creates implicit properties from the 
Java  system properties and do something like this:

    <property file="${user.home}/user.properties"/>

This will load the user's specific properties file from their home 
directory.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere v7 Release Engineer
WebSphere Build Tooling Lead (Project Mantis)


"Bill Rich" <bi...@wilandra.com> wrote on 11/05/2005 08:05:04 PM:

> Ahh, but is even better to take advantage of the fact that properties 
are
> immutable.
> 
> For example, I have a file called user.properties that contains some 
default
> property settings. If the user does not want to use them then she just
> specifies a user name on the command line and the user.properties file 
is
> not loaded, instead a tailored user properties file is loaded. Because 
the
> property is immutable the value assigned to the property USER will 
either
> come from the command line or from the declaration in the build file.
> 
> <property name="USER" value="user"/>
>   <echo message="Loading${USER}.properties."/>
>   <property file="${USER}.properties"/> 
> 
> To specify a user name on the command line use -DUSER=br.
> 
> HTH Bill
> 
> -----Original Message-----
> From: Mark McKay [mailto:mark@kitfox.com] 
> Sent: Saturday, November 05, 2005 4:43 PM
> To: user@ant.apache.org
> Subject: Specifiying user properties file
> 
> I'm trying to set up a situation where my users can specify a properties
> file where they can set properties specific to their machines.  I have 
my
> main build.xml file checked into my CVS repostiory, and a 
default.properties
> file that is also in the CVS repository.  I'd like the init task of my 
ant
> script to check if a file called user.properties exists, and if so to 
load
> properties from that file.  Otherwise, I'd like it to load properties 
fron
> the default.properties file.
> 
> Is there a way to do this (or something similar)?  Ant's lack of an <if>
> task makes setting up something like this difficult.
> 
> Mark McKay
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
> commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

RE: Specifiying user properties file

Posted by Bill Rich <bi...@wilandra.com>.
Ahh, but is even better to take advantage of the fact that properties are
immutable.

For example, I have a file called user.properties that contains some default
property settings. If the user does not want to use them then she just
specifies a user name on the command line and the user.properties file is
not loaded, instead a tailored user properties file is loaded. Because the
property is immutable the value assigned to the property USER will either
come from the command line or from the declaration in the build file.

<property name="USER" value="user"/>
  <echo message="Loading${USER}.properties."/>
  <property file="${USER}.properties"/> 

To specify a user name on the command line use -DUSER=br.

HTH Bill

-----Original Message-----
From: Mark McKay [mailto:mark@kitfox.com] 
Sent: Saturday, November 05, 2005 4:43 PM
To: user@ant.apache.org
Subject: Specifiying user properties file

I'm trying to set up a situation where my users can specify a properties
file where they can set properties specific to their machines.  I have my
main build.xml file checked into my CVS repostiory, and a default.properties
file that is also in the CVS repository.  I'd like the init task of my ant
script to check if a file called user.properties exists, and if so to load
properties from that file.  Otherwise, I'd like it to load properties fron
the default.properties file.

Is there a way to do this (or something similar)?  Ant's lack of an <if>
task makes setting up something like this difficult.

Mark McKay

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org