ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: failonerror for target and depends
Date Thu, 23 Jul 2009 20:35:20 GMT
When you state that a target "A"is dependent upon target "B", target "B"
MUST run and execute before target "A" can execute.

Ant isn't a programming language. It is a dependency matrix. You specify
which targets are dependent upon other targets, and Maven will sort out the
build order for you. Are your "depends" other targets, or are you treating
them as command line parameters?

Here's how depends work:

   <target name="clean"/>
   <target name="getsource"/>
   <target name="compile" depends="getsource"/>
   <target name="test depends="compile"/>
   <target name="package" depends="compile"/>
   <target name="deploy" depends="package"/>

In this shell of a build script, if I do

*$ ant package*

Ant will look at target "package", and determine that it depends upon target
"compile". Target "compile" depends upon target "getsource", so Ant will run
targets "getsource", "compile", and "package" in that order.

Note that target "clean" and target "test" don't get executed because
they're not in the dependency matrix that Ant built. Also notice that all
targets mentioned in the "depends" parameter must exist, and that a failure
in any previously executed target will cause the build to fail.

If you are trying to build a "subroutine", you should look at the <macroDef>
task. You can define a macro that can have optional and required parameters:

*<target name="foo">*
*   <bar init2="fubar" init3="barfoo"/>*

*<macrodef name="bar">*
*   <attribute name="init1" default="NOT-SET"/>*
*   <attribute name="init2/>*
*   <attribute name="init3 default="SOME VALUE"/>*
*   <sequential>*
*      <echo>Called macro "bar" with parameters @{init1}, @{init2}, and
*   </sequential>*

In the above, target "foo" calles the macro you defined, "bar". Because
there is no default value, you must include "init2" when calling bar.
However, you don't need "init1" or "init3" because they have default values.

Is this more what you're looking for?

On Thu, Jul 23, 2009 at 12:46 PM, dkhanna123 <> wrote:

> I have a target defined as :
> <target name="prompt" depends="-init1,-init2,-init3">
> Now I want when ant call prompt target and if "init1" DOESNOT exist then it
> should continue with init2 and init3.
> I have used ant -k option but instead of continuing with init2 and init3
> the
> whole prompt target exits.
> ANy suggestions
> --
> 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