Hi
I understand how depends works but my question is..
If I have two targets defined in depends for e.g depends="target1,target2",
and if some how target1 does not exist and instead of throwing error ant
should move ahead (after showing some warning) and execute target2.
THanks
David Weintraub wrote:
>
> 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:
>
> *<project>
> <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"/>
> </project*
>
> 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"/>*
> *</target>*
>
> *<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
> @{init3}</echo>*
> * </sequential>*
> *</macrodef>*
>
> 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 <[email protected]> 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:
>> http://www.nabble.com/failonerror-for-target-and-depends-tp24629812p24629812.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> David Weintraub
> [email protected]
>
>
--
View this message in context:
http://www.nabble.com/failonerror-for-target-and-depends-tp24629812p24635303.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]