Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

Using <condition/> to set a property with "location" semantics?

Cyril Sagan

2008-05-23

Replies: Find Java Web Hosting

Author LoginPost Reply
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@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.