ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: BUILD FAILED messages in output when using <Ant/> tasks
Date Thu, 18 Jun 2009 13:19:43 GMT
The BUILD FAILED messages are not printed during the call to task "test2",
but after "test2" exits due to an error. They are part of the output from
Ant and not the task itself.

If you want the BUILD FAILED output, you need to first capture the output of
Ant and not of a single task. You also need to redirect STDERR into STDOUT
since the "BUILD FAILED" message prints on STDERR. In Unix, you can do this:

$ ant test1 2>&1 | tee ant.out

In Windows, it's something like this:

C:> ant test1 > ant.out 2>&1

Unlike Unix, this won't print the output on the console.

Another possibility is to use the "try/catch" tasks in the AntContrib
package. This allows you to "try" a task, and if it fails, do your own
response. This way, you could append a "BUILD FAILED" message onto your log

Another possibility is to capture the exit status of the Ant command and
append the BUILD FAILED message to the log if the ant command returns a
non-zero error.

On Wed, Jun 17, 2009 at 7:02 PM, 5dark <> wrote:

> Hey all.
> I notice when using the <ant output="mylog.txt" .../> task if a exception
> or
> error occurs in the Ant project then the error doesn't show up in the <ant>
> task's output file (in this example "mylog.txt").
> EG:
> with ant code:
>   <target name="test1">
>      <ant dir="${basedir}" inheritAll="false"
>         target="test2" output="${basedir}\mylog.txt">
>         <property name="myparam" value="what"/>
>      </ant>
>   </target>
>   <target name="test2">
>      <taskdef/>
>   </target>
> The output is (ignore the line numbers):
>   test1:
>   test2:
>   C:\work\WS\build\build.xml:4580: The following error occurred while
> executing this line:
>   C:\work\WS\build\build.xml:4586: Only antlib URIs can be located from the
> URI alone,not the URI
> But the contents of mylog.txt is just:
>   test2:
> Is there anyway to make the error show up in the output file (mylog.txt)?
> Thanks!
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

David Weintraub

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message