ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yyy Xxx <gj...@yahoo.com>
Subject RE: Path question
Date Thu, 03 Oct 2002 18:35:34 GMT
Use "location" instead of "value" in your property task.  It will
normalize the path and also document that you are dealing with files
instead of arbitrary strings.

Here's an example:

<target name="test2">
 <property name="buildDir-value" value="${basedir}/${BuildNumber}"/>
 <property name="buildDir-location"
location="${basedir}/${BuildNumber}"/>
 <property name="InstallShieldComponentsDir-value"
value="${buildDir-value}/ISComponent"/>
 <property name="InstallShieldComponentsDir-location1"
location="${buildDir-value}/ISComponent"/>
 <property name="InstallShieldComponentsDir-location2"
location="${buildDir-location}/ISComponent"/>
 <echo>
  buildDir-value = ${buildDir-value}
  buildDir-location = ${buildDir-location}
  InstallShieldComponentsDir-value =
${InstallShieldComponentsDir-value}
  InstallShieldComponentsDir-location1 =
${InstallShieldComponentsDir-location1}
  InstallShieldComponentsDir-location2 =
${InstallShieldComponentsDir-location2}
 </echo>
</target>




By the way, here's a "best practice" convention that I use:

Define file properties in triplets:

   xxx.location == Location of file xxx (path & filename)
   xxx.dir      == Directory of file xxx
   xxx.filename == Filename (w/ext) of file xxx

An easy way to do this is:

   <property name="xxx.location" location="..."/>

   <dirname file="${xxx.location}" property="xxx.dir"/>
   <basename file="${xxx.location}" property="xxx.filename"/>

Then it's easy to keep your properties straight.


> -----Original Message-----
> From: Stephenson, Martin [mailto:martin.stephenson@daon.com]
> Sent: Thursday, October 03, 2002 6:27 AM
> To: 'ant-user@jakarta.apache.org'
> Subject: Path question
> 
> 
> Hi all
> 
> I have a property called "buildDir" setup as follows:
> 
> <property name="buildDir" value="${basedir}/${BuildNumber}"/>
> 
> And I also have a property "InstallShieldComponentsDir"
> 
> <property name="InstallShieldComponentsDir"
> value="${buildDir}/ISComponents"/>
> 
> Now, I'm calling a batch file, which in turn calls a program 
> with takes the
> Path stored in "InstallShieldComponentsDir"
> 
> My problem is that "InstallShieldComponentsDir" has the 
> following as an
> actual value:
> 
> F:\Development/Builds/1.0.0.0/ISComponents
> 
> But the program I'm calling doesn't like the forward-slash - it
want's
> Backslashes, ie.:
> 
> F:\Development\Builds\1.0.0.0\ISComponents
> 
> Is there some way I can search and replace the \ with a / in 
> the property ?
> 
> Thanks
> 
> Martin
> 

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

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


Mime
View raw message