ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cyril Sagan <Cyril.Sa...@sas.com>
Subject Using <condition/> to set a property with "location" semantics?
Date Fri, 23 May 2008 16:03:16 GMT
Has anyone else ever wished there was a way to specify "location semantics" for <condition/>
values?

Given that doesn't exist, can anyone suggest the ideal way to implement:

   $ cd /tmp/X/Y/script/
   $ cat build.xml
   <?xml version="1.0" encoding="utf-8"?>
   <project name="ant_dev_sample">
       <property name="tmp.path"  location="${basedir}/../.." />
       <condition property="some.dir" value="${tmp.path}">
           <isset property="some.property" />
       </condition>
       <echo>some.dir: ${some.dir}</echo>
   </project>

   $ ant -Dsome.property=true
   Buildfile: build.xml
        [echo] some.dir: /tmp/X

   BUILD SUCCESSFUL
   Total time: 0 seconds



This is exactly what I want, a full and resolved path.
However, without the property, I get a relative path, not ideal.

   $ cat build.xml
   <?xml version="1.0" encoding="utf-8"?>
   <project name="ant_dev_sample2">
       <condition property="some.dir" value="${basedir}/../..">
           <isset property="some.property" />
       </condition>
       <echo>some.dir: ${some.dir}</echo>
   </project>

   $ ant -Dsome.property=true
   Buildfile: build.xml
        [echo] some.dir: /tmp/X/Y/script/../..

   BUILD SUCCESSFUL
   Total time: 0 seconds

                        ^^^^^^^^^^^^^^^^^^^^^^^^^ Yuck!


Thanks in advance for your more elegant solution!

--Cyril


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


Mime
View raw message