ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John W. Lewis" <JohnW.Le...@sas.com>
Subject RE: Need cross platform way of assigning users name to a property
Date Tue, 22 Jun 2010 15:52:31 GMT

I had a similar problem:

			<condition property="appdata.dir" value="${env.USERPROFILE}\Application Data\MyProject">
				<os family="windows"  />
			</condition>
			<condition property="appdata.dir" value="${env.HOME}/.myproject">
				<os family="unix"  />
			</condition>


-----Original Message-----
From: Dean Schulze [mailto:dean_w_schulze@yahoo.com] 
Sent: Tuesday, June 22, 2010 11:25 AM
To: user@ant.apache.org
Subject: Need cross platform way of assigning users name to a property

My build.xml starts with the following lines:
 
<property environment="env"/>
<property name="user.username.dir" value="user/${env.USERNAME}"/>
<import file="${user.username.dir}/build.local.xml" optional="true"/>
 
This imports a build.local.xml file that holds machine-specific properties for each developer.
 
The problem is that this does not work on UNIX because the username is in env.USER in unix. 
I need a cross-platform way to assign a user.name property in Ant.  
 
This has to be done at the top of the build.xml so that the <import ... /> is done before
any other property assignments (the properties in build.local.xml are used if build.local.xml
exists).  This means that the user.name property can't be assigned in a target so the condition
statement is useless here.
 
Is there some way that I can read the username from the environment in a cross-platform way
given that it has to happen at the top of the script?
 
 


      

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


Mime
View raw message