You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefan Bodewig <bo...@apache.org> on 2002/11/11 09:37:23 UTC

Re: Using available's property setting ability inside a condition, is it possible?

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>


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>