ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Budworth <>
Subject Re: Using available's property setting ability inside a condition, is it possible?
Date Mon, 11 Nov 2002 16:45:35 GMT
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}">
      <isset property="compiler.type"/>
      <available file="${compiler.type}" filepath="${env.PATH}"/>
  <condition property="found.compiler" value="jikes">
        <isset property="compiler.type"/>
      <available file="jikes" filepath="${env.PATH}"/>
  <condition property="found.compiler" value="javac">
        <isset property="compiler.type"/>
      <available file="javac" filepath="${env.PATH}"/>
  <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>

On Mon, 2002-11-11 at 00:37, Stefan Bodewig wrote:
> On 09 Nov 2002, David Budworth <> 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:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message