ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: question regarding WSAD specific ant tasks
Date Wed, 04 Jun 2003 13:59:42 GMT

I was browsing the list archives and found another way to utilize the fail
tast to terminate the build when compile errors occur.  It's really not a
pretty way to do things, but it does stop the build when necessary.

<target name="jar_credit1utils" >

          <eclipse.refreshLocal resource="${common_project}" />

          <projectBuild ProjectName="${common_project}" failonerror="true"
DebugCompilation="true" BuildType="full" />

          <getJavacErrorCount ProjectName="${common_project}" PropertyName
="MyJavacErrorCount" />

          <echo message="MyJavacErrorCount=${MyJavacErrorCount}" />

          <!-- create a property based on the number of compile time errors.  This slick
nastiness is
                 necessary because projectBuild does not terminate when compile errors are
                 regardless of the value of the failonerror attribute. -->
          <property name="javaErrors${MyJavacErrorCount}" value="foo" />

          <!-- this echoes the name of the property created based on the number of compile
errors from projectBuild -->
          <echo message="javaErrors${MyJavacErrorCount}" />

          <!-- the build fails unless a property named javaErrors0 has been created, signifying
a clean java compile -->
          <fail unless="javaErrors0" message="Build Failed due to ${MyJavacErrorCount}
compile errors." />

          <utilJar EARProjectName="${ear_project}" JavaProjectName="${common_project}"
Jar="./lib/credit1utils.jar" />


Jon Culli

Senior Developer
Bank One (
Phone: 1-312-661-6354

"North Alex" <> on 06/04/2003 02:34:55 AM

Please respond to "Ant Users List" <>

To:   "Ant Users List" <>

Subject:  RE: question regarding WSAD specific ant tasks

>My question is regarding behavior of the <projectBuild> task
>when there is at least one compile error present.  The
><projectBuild> task is not failing or terminating when there
>is a compile error present regardless of the value of the
>"failonerror" attribute.  I get a "BUILD SUCCESSFUL" message
>after the task even though compile problems are noted in the
>trace.  Is this the expected behavior or am I somehow missing

I came across the same problem (running inside WSAD 5) ... here is my

<target name="do.compile" depends="clean">
    <projectBuild ProjectName="${}" failonerror="true"
          DebugCompilation="true" BuildType="full"/>

    <getJavacErrorCount ProjectName="${}"
        PropertyName="compile.error.count" />
    <condition property="build.ok">
        <equals arg1="${compile.error.count}" arg2="0"/>

<target name="" unless="build.ok">
  <fail>Failed while compiling ${}</fail>

<target name="Compile" depends="do.compile,">

If there is a nicer way to do this, I'd like to know.

<= Alex =>

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

This transmission may contain information that is privileged, confidential and/or exempt from
disclosure under applicable law. If you are not the intended recipient, you are hereby notified
that any disclosure, copying, distribution, or use of the information contained herein (including
any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error,
please immediately contact the sender and destroy the material in its entirety, whether in
electronic or hard copy format. Thank you.

View raw message