I don't think it is possible, but I wanted to confirm here.

My goal is to be platform agnostic, and not get mixed separators in path
names, in order to accomplish this I don't think I can use <condition/>.

While I prefer to use "pure ant", in this case I think the <if/> is better
than lots of ${path.separtor}'s in strings.

Consider this example:

OUTPUT:   (note mixed separators)
C:\temp>ant -version
Apache Ant version 1.7.0 compiled on December 13 2006

C:\temp>ant
Buildfile: build.xml
     [echo] dir.works = C:\temp\false\demo\path
     [echo] dir.fails = C:\temp/false/demo/path

BUILD SUCCESSFUL
Total time: 0 seconds

>From this build.xml:

<?xml version="1.0" encoding="utf-8"?>
<project name="condition-property-semantics-test">
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <if>
        <istrue value="${some.property}" />
        <then>
            <property name="dir.works"
                      location="${basedir}/true/option" />
        </then>
        <else>
            <property name="dir.works"
                      location="${basedir}/false/demo/path" />
        </else>
    </if>

    <!-- not equivalent to above on windows, ${dir}
         will have both forward and backward slashes -->
    <condition property="dir.fails"
               value="${basedir}/true/option"
               else="${basedir}/false/demo/path">
        <istrue value="${some.property}" />
    </condition>

    <echo>dir.works = ${dir.works}</echo>
    <echo>dir.fails = ${dir.fails}</echo>
</project>

Anyone have any other suggested solution?   Thanks.

--Cyril

Reply via email to