You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David Budworth <dl...@nustiu.net> on 2002/11/09 23:43:00 UTC
Using available's property setting ability inside a condition, is
it possible?
Hi All,
I'm finding that the following doesn't work:
<target name="find.compiler">
<condition property="compiler.found">
<or>
<available file="jikes" filepath="${env.PATH}"
property="compiler.type" value="jikes"/>
<available file="javac" filepath="${env.PATH}"
property="compiler.type" value="javac"/>
</or>
</condition>
<echo>Compiler found: ${compiler.found}, type: ${compiler.type}</echo>
</target>
output:
[echo] Compiler found: true, type: ${compiler.type}
The compiler type never gets set.
If I move the available directives outside the condition and comment out
the condition section I get:
[echo] Compiler found: ${compiler.found}, type: jikes
The ${compiler.found} part is expected in the second output since I
removed the condition. But, as you can see, ${compiler.type} gets set
just fine.
The only workaround for this I can find is to do it the old way, of
multiple targets with an "unless=compiler.type" tag on them.
Is this a bug? I found no mention in the docs for condition saying you
can't set properties inside it like that.
Thank you
-David Budworth
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using available's property setting ability inside a condition, isit possible?
Posted by Martin <mg...@hotmail.com>.
On a related note
How does one extend the classpath in java task
I set classpath as such
<java classpath="./lib/newjar.jar;${classpath}" ....
but I find this classpath specification does not work
I find that adding a property into global classpath works
Am I implementing classpath in java correctly?
Thank You,
Martin
----- Original Message -----
From: "Kendall Collett" <kc...@convio.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Saturday, November 09, 2002 6:58 PM
Subject: Re: Using available's property setting ability inside a condition,
isit possible?
> In the documentation for the nested elements of <condition> (see
> <http://jakarta.apache.org/ant/manual/CoreTasks/conditions.html>), it
says:
> available
> This condition is identical to the Available task, all attributes and
> nested elements of that task are supported, *the property and value
> attributes are redundant and will be ignored*.
>
> Kendall
>
> ----- Original Message -----
> From: "David Budworth" <dl...@nustiu.net>
> To: "ANT User List" <an...@jakarta.apache.org>
> Sent: Saturday, November 09, 2002 16:43
> Subject: Using available's property setting ability inside a condition,
isit
> possible?
>
>
> > Hi All,
> >
> > I'm finding that the following doesn't work:
> > <target name="find.compiler">
> > <condition property="compiler.found">
> > <or>
> > <available file="jikes" filepath="${env.PATH}"
> > property="compiler.type" value="jikes"/>
> > <available file="javac" filepath="${env.PATH}"
> > property="compiler.type" value="javac"/>
> > </or>
> > </condition>
> > <echo>Compiler found: ${compiler.found}, type: ${compiler.type}</echo>
> > </target>
> >
> > output:
> > [echo] Compiler found: true, type: ${compiler.type}
> >
> >
> > The compiler type never gets set.
> >
> > If I move the available directives outside the condition and comment out
> > the condition section I get:
> > [echo] Compiler found: ${compiler.found}, type: jikes
> >
> >
> > The ${compiler.found} part is expected in the second output since I
> > removed the condition. But, as you can see, ${compiler.type} gets set
> > just fine.
> >
> > The only workaround for this I can find is to do it the old way, of
> > multiple targets with an "unless=compiler.type" tag on them.
> >
> > Is this a bug? I found no mention in the docs for condition saying you
> > can't set properties inside it like that.
> >
> > Thank you
> > -David Budworth
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using available's property setting ability inside a condition, isit possible?
Posted by Kendall Collett <kc...@convio.com>.
In the documentation for the nested elements of <condition> (see
<http://jakarta.apache.org/ant/manual/CoreTasks/conditions.html>), it says:
available
This condition is identical to the Available task, all attributes and
nested elements of that task are supported, *the property and value
attributes are redundant and will be ignored*.
Kendall
----- Original Message -----
From: "David Budworth" <dl...@nustiu.net>
To: "ANT User List" <an...@jakarta.apache.org>
Sent: Saturday, November 09, 2002 16:43
Subject: Using available's property setting ability inside a condition, isit
possible?
> Hi All,
>
> I'm finding that the following doesn't work:
> <target name="find.compiler">
> <condition property="compiler.found">
> <or>
> <available file="jikes" filepath="${env.PATH}"
> property="compiler.type" value="jikes"/>
> <available file="javac" filepath="${env.PATH}"
> property="compiler.type" value="javac"/>
> </or>
> </condition>
> <echo>Compiler found: ${compiler.found}, type: ${compiler.type}</echo>
> </target>
>
> output:
> [echo] Compiler found: true, type: ${compiler.type}
>
>
> The compiler type never gets set.
>
> If I move the available directives outside the condition and comment out
> the condition section I get:
> [echo] Compiler found: ${compiler.found}, type: jikes
>
>
> The ${compiler.found} part is expected in the second output since I
> removed the condition. But, as you can see, ${compiler.type} gets set
> just fine.
>
> The only workaround for this I can find is to do it the old way, of
> multiple targets with an "unless=compiler.type" tag on them.
>
> Is this a bug? I found no mention in the docs for condition saying you
> can't set properties inside it like that.
>
> Thank you
> -David Budworth
>
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using available's property setting ability inside a condition, is it possible?
Posted by Stefan Bodewig <bo...@apache.org>.
On 11 Nov 2002, David Budworth <dl...@nustiu.net> wrote:
> Actually, this is what I tried from the start But you get a
> deprecation warning about using available to overwrite an existing
> property
OK, so instead of
>> <available file="jikes" filepath="${env.PATH}"
>> property="compiler.type" value="jikes"/>
>> <available file="javac" filepath="${env.PATH}"
>> property="compiler.type" value="javac"/>
You could use
<available file="jikes" filepath="${env.PATH}"
property="compiler.type" value="jikes"/>
<condition property="compiler.type" value="javac">
<and>
<not>
<isset property="compiler.type"/>
</not>
<available file="javac" filepath="${env.PATH}"/>
</and>
</condition>
Still easier than your version.
Stefan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using available's property setting ability inside a condition,
is it possible?
Posted by David Budworth <dl...@nustiu.net>.
Actually, this is what I tried from the start
But you get a deprecation warning about using available to overwrite an
existing property
I ended up doing what's below. Looking at it now though, I'm not sure
why ${found.compiler} doesn't get overwritten with javac after it's
found jikes (both are in my path). But I'd guess that that's a feature
of condition (non-overriding). At any rate, this lets you specify the
compiler (it assumes the compiler type is the same as the binary to
execute ie: jikes=jikes, javac=javac, won't work on windows), or will
auto-detect the jikes/javac for you.
<target name="find.compiler">
<condition property="found.compiler" value="${compiler.type}">
<and>
<isset property="compiler.type"/>
<available file="${compiler.type}" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="found.compiler" value="jikes">
<and>
<not>
<isset property="compiler.type"/>
</not>
<available file="jikes" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="found.compiler" value="javac">
<and>
<not>
<isset property="compiler.type"/>
</not>
<available file="javac" filepath="${env.PATH}"/>
</and>
</condition>
<fail unless="found.compiler" if="compiler.type"
message="Failed to find specified compiler: ${compiler.type}"/>
<fail unless="found.compiler"
message="Failed to find jikes or javac in your path"/>
<property name="compiler.type" value="${found.compiler}"/>
<echo>Compiler Type: ${compiler.type}</echo>
</target>
On Mon, 2002-11-11 at 00:37, Stefan Bodewig wrote:
> On 09 Nov 2002, David Budworth <dl...@nustiu.net> wrote:
>
> > The only workaround for this I can find is to do it the old way, of
> > multiple targets with an "unless=compiler.type" tag on them.
>
> So I'll try to help to find another one:
>
> <available file="jikes" filepath="${env.PATH}"
> property="compiler.type" value="jikes"/>
> <available file="javac" filepath="${env.PATH}"
> property="compiler.type" value="javac"/>
> <condition property="compiler.found">
> <isset property="compiler.type"/>
> </condition>
> <echo>Compiler found: ${compiler.found}, type: ${compiler.type}</echo>
>
> Stefan
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Using available's property setting ability inside a condition, is it possible?
Posted by Stefan Bodewig <bo...@apache.org>.
On 09 Nov 2002, David Budworth <dl...@nustiu.net> wrote:
> The only workaround for this I can find is to do it the old way, of
> multiple targets with an "unless=compiler.type" tag on them.
So I'll try to help to find another one:
<available file="jikes" filepath="${env.PATH}"
property="compiler.type" value="jikes"/>
<available file="javac" filepath="${env.PATH}"
property="compiler.type" value="javac"/>
<condition property="compiler.found">
<isset property="compiler.type"/>
</condition>
<echo>Compiler found: ${compiler.found}, type: ${compiler.type}</echo>
Stefan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>