ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: How to find available targets in a build file
Date Tue, 19 Mar 2002 21:47:06 GMT
--- Steve Loughran <> wrote:
> ----- Original Message -----
> From: "Shah, Lokesh" <>
> To: <>
> 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

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

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



Do You Yahoo!?
Yahoo! Sports - live college hoops coverage

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

View raw message