ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: How to find available targets in a build file
Date Tue, 19 Mar 2002 21:47:06 GMT
--- Steve Loughran <steve_l@iseran.com> wrote:
> ----- Original Message -----
> From: "Shah, Lokesh" <lokesh.shah@iona.com>
> To: <ant-user@jakarta.apache.org>
> Sent: Monday, March 18, 2002 5:07 PM
> Subject: How to find available targets in a build file
> 
> >Is there any way I can check if a target is available in a build file?
> 
> not yet

Yes and no. "Not yet" in the sense of in a released version, but
1.5alpha's <exec> has a 'resultproperty' attribute you can use to capture
the return code of the command you execute. So you could do something
like:

<target name="doConditionalTarget" depends="chkTarget" if="target.found">
  <ant ... />
</target>

<target name="chkTarget">
  <exec executable="sh" dir="subdir"
        resultproperty="grep.rc" os="FreeBSD">
    <arg line='-c "ant -projecthelp -verbose|grep -q findit"'/>
  </exec>
  <exec executable="cmd" dir="subdir"
        resultproperty="grep.rc" os="Windows NT">
    <arg line='/c "ant -projecthelp -verbose|findstr 1>nul 2>nul
findit"'/>
  </exec>
  <condition property="target.found">
    <equals arg1="${grep.rc}" arg2="0"/>
  </condition>
</target>

Diane

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



__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

--
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