ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Budworth <dlb...@nustiu.net>
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}">
    <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 <dlbant@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:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>




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


Mime
View raw message