ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <qazw...@gmail.com>
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
yourself.

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 <5darksigns@gmail.com> 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:
>
>   BUILD FAILED
>   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:
> http://www.nabble.com/BUILD-FAILED-messages-in-output-when-using-%3CAnt-%3E-tasks-tp24083705p24083705.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


-- 
David Weintraub
qazwart@gmail.com

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