You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "John-Mason P. Shackelford" <jo...@shackelford.org> on 2002/06/20 01:45:08 UTC

trouble with conditions for multiple JDK support

Greetings,

The <condition> tag is not behaving as expected in ant 1.5 beta 2. 
Perhaps this is a case of bad expectations :p

In any case I am trying to write a generic compile target which I can 
call from other targets and specify which JDK to use. I do not want my 
users to have to specify the path to the executable for every single 
target in the system, it should be enough for them to define the path to 
the executables once and then to indicate which compiler type to use for 
each target, e.g.

modern.jdk.path = c:\jdk131
classic.jdk.path = c:\jdk131
example1.compiler.type = modern
example2.compiler.type = classic

The following build.xml ought to simulate this, but for some reason 
use.jdk.path is never set. If this is the wrong approach, could someone 
suggest an alternative?

Thanks!

John-Mason Shackelford

build.xml
--------
<project name="myproject" default="example1">

<!-- set these in a property file -->
<property name="modern.jdk.path" location="c:\jdk131"/>
<property name="classic.jdk.path" location="c:\jdk118"/>
<property name="example1.compiler.type"    value="modern"/>
<property name="example2.compiler.type"    value="classic"/>

<target name="example1">
    <echo>example target one</echo>
    <antcall target="routine">
        <param name="compiler.type" value="${example1.compiler.type}"/>
    </antcall>
</target>


<target name="example2">
    <echo>example target two</echo>
    <antcall target="routine">
        <param name="compiler.type" value="${example2.compiler.type}"/>
    </antcall>
</target>

<target name="routine">

    <condition property="use.jdk.path" value="${modern.jdk.path}">
    <and>
        <equals arg1="compiler.type" arg2="modern" trim="true" 
casesensitive="false"/>
        <isset property="${modern.jdk.path}"/>
    </and>
     </condition>

    <condition property="use.jdk.path" value="${classic.jdk.path}">
    <and>
        <equals arg1="compiler.type" arg2="classic" trim="true" 
casesensitive="false"/>
        <isset property="${classic.jdk.path}"/>
    </and>
    </condition>
    
    <echo>modern.jdk.path  = ${modern.jdk.path}</echo>
    <echo>classic.jdk.path = ${classic.jdk.path}</echo>
    <echo>compiler.type    = ${compiler.type}</echo>

    <echo>compiling with ${compiler.type} using JDK in 
${use.jdk.path}</echo>

</target>

</project>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: trouble with conditions for multiple JDK support

Posted by Diane Holt <ho...@yahoo.com>.
--- "John-Mason P. Shackelford" <jo...@shackelford.org> wrote:
> The <condition> tag is not behaving as expected in ant 1.5 beta 2. 
> Perhaps this is a case of bad expectations :p

Nope -- bad syntax. You've got the "${}" construct where you shouldn't,
and you don't have it where you should.

> <target name="routine">
> 
>     <condition property="use.jdk.path" value="${modern.jdk.path}">
>     <and>
>         <equals arg1="compiler.type" arg2="modern" trim="true"
                        ^^^^^^^^^^^^^ ${compiler.type} 
> casesensitive="false"/>
>         <isset property="${modern.jdk.path}"/>
                           ^^^^^^^^^^^^^^^^^^ modern.jdk.path

(Same for the other <condition>.)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>