You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Cyril Sagan <cy...@gmail.com> on 2013/12/12 00:07:54 UTC

Is it possible to get "location semantics" with

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

Re: Is it possible to get "location semantics" with

Posted by Edwin Castro <0p...@gmx.us>.
On 12/11/13, 3:07 PM, Cyril Sagan wrote:
>     <!-- 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>

Could you spare a "temporary" property? Something like

<condition property="dir.fails.tmp"
           value="${basedir}/true/option"
           else="${basedir}/false/demo/path">
    <istrue value="${some.property}"/>
</condition>

<property name="dir.fails" location="${dir.fails.tmp}"/>

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

--
Edwin


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


AW: Is it possible to get "location semantics" with

Posted by "Jan Matèrne (jhm)" <ap...@materne.de>.
I would use several properties files and load the one needed for the current
environment.

<property file="${os.name}.properties"/>


Jan

> -----Ursprüngliche Nachricht-----
> Von: Cyril Sagan [mailto:cyril.sagan@gmail.com]
> Gesendet: Donnerstag, 12. Dezember 2013 00:08
> An: Ant Users List
> Betreff: Is it possible to get "location semantics" with <condition/>
> 
> 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


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


Re: Is it possible to get "location semantics" with

Posted by Edwin Castro <0p...@gmx.us>.
On 12/11/13, 3:07 PM, Cyril Sagan wrote:
> C:\temp>ant
> Buildfile: build.xml
>      [echo] dir.works = C:\temp\false\demo\path
>      [echo] dir.fails = C:\temp/false/demo/path

Have you seen paths with mixed separators actually cause problems?

I'm no longer on Windows but my experience was that it didn't matter as
Windows handled paths with mixed separators correctly.


--
Edwin


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