You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Vincent Li <vi...@starcite.com> on 2007/12/25 09:48:50 UTC
Hi, Ant dev, I have questiones on multiple run Target
Hi Ant dev,
I found Ant can't run a target multiple times, a small example is
followed, could you please hint me how to make it work??
Source Code:
<project name="11" default="all" basedir=".">
<target name="all" depends="aaaa, bbbb, aaaa, bbbb" />
<target name="aaaa">
<echo message="aaaaa" />
</target>
<target name="bbbb">
<echo message="bbbbb" />
</target>
</project>
Output:
Buildfile: D:\test.xml
aaaa:
[echo] aaaaa
bbbb:
[echo] bbbbb
all:
BUILD SUCCESSFUL
Total time: 234 milliseconds
What I am expecting is that both "aaaaa" and "bbbbb" should shown twice,
how can I achieve this?
Looking forward for your reply,
Thanks
Vincent
Re: Hi, Ant dev, I have questiones on multiple run Target
Posted by "Jack J. Woehr" <jw...@absolute-performance.com>.
Frank W. Zammetti wrote:
> This is just a guess, I don't know this for sure, but I wouldn't be
> surprised to learn it has to do with dependencies.
Dependencies are a chain, you are right. Once filled, they're filled for
that chain of actions.
In any case, you can always explicitly call a target with <antcall>.
--
Jack J. Woehr
Director of Development
Absolute Performance, Inc.
jwoehr@absolute-performance.com
303-443-7000 ext. 527
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Hi, Ant dev, I have questiones on multiple run Target
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
This is just a guess, I don't know this for sure, but I wouldn't be
surprised to learn it has to do with dependencies... i.e., isn't this in
effect saying that task aaaa (the second time) is dependent on task
aaaa?!? Bit of a paradox there I'd think! I can envision a pretty
logical implementation of dependency tracking that would result in this
behavior too (although I have no clue how Ant implements it).
That's just a guess, and I'm looking forward to an answer from someone
who knows what they're talking about because it's an interesting
question. FYI, I personally would use antcall for a situation like
this, make the targets much more like reusable functions than dependent
task, but that's just me.
Frank
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
(2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
(2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!
Vincent Li wrote:
> Hi Ant dev,
>
>
>
> I found Ant can't run a target multiple times, a small example is
> followed, could you please hint me how to make it work??
>
>
>
> Source Code:
>
> <project name="11" default="all" basedir=".">
>
> <target name="all" depends="aaaa, bbbb, aaaa, bbbb" />
>
>
>
> <target name="aaaa">
>
> <echo message="aaaaa" />
>
> </target>
>
>
>
> <target name="bbbb">
>
> <echo message="bbbbb" />
>
> </target>
>
> </project>
>
>
>
> Output:
>
> Buildfile: D:\test.xml
>
> aaaa:
>
> [echo] aaaaa
>
> bbbb:
>
> [echo] bbbbb
>
> all:
>
> BUILD SUCCESSFUL
>
> Total time: 234 milliseconds
>
>
>
> What I am expecting is that both "aaaaa" and "bbbbb" should shown twice,
> how can I achieve this?
>
> Looking forward for your reply,
>
>
>
>
>
>
>
> Thanks
>
> Vincent
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.9/1198 - Release Date: 12/26/2007 5:26 PM
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Hi, Ant dev, I have questiones on multiple run Target
Posted by David Weintraub <qa...@gmail.com>.
Dependencies are simply dependencies and are not explicit directions
on what order to do a build in. When ant executes, it builds a
dependency tree and then steps through that tree building the earliest
dependencies first. There are times when dependencies may be built out
of order the way they are listed. For example:
<target name="target1" depends="target2,target3"/>
<target name="target2" depends="target3"/>
<target name="target3"/>
If I say "ant target1", the first item to be built will be "target3"
even though "target2" is listed first.
What is happening is that Ant is building a dependency matrix, and
calculates out that target "aaaa" and "bbbb" have to be built before
target "all". So, it builds those two targets. It could have just as
easily built "bbbb" before "aaaa" since neither has any dependency on
the other.
I am actually surprised you didn't get an error message that you have
the same dependency listed multiple times.
If you MUST specify a build order (and if you do, you're probably
missing something. The whole concept of Ant is that Ant should be
calculating out your build order and not you), you need to do
<antcall>.
On Dec 25, 2007 3:48 AM, Vincent Li <vi...@starcite.com> wrote:
> Hi Ant dev,
>
>
>
> I found Ant can't run a target multiple times, a small example is
> followed, could you please hint me how to make it work??
>
>
>
> Source Code:
>
> <project name="11" default="all" basedir=".">
>
> <target name="all" depends="aaaa, bbbb, aaaa, bbbb" />
>
>
>
> <target name="aaaa">
>
> <echo message="aaaaa" />
>
> </target>
>
>
>
> <target name="bbbb">
>
> <echo message="bbbbb" />
>
> </target>
>
> </project>
>
>
>
> Output:
>
> Buildfile: D:\test.xml
>
> aaaa:
>
> [echo] aaaaa
>
> bbbb:
>
> [echo] bbbbb
>
> all:
>
> BUILD SUCCESSFUL
>
> Total time: 234 milliseconds
>
>
>
> What I am expecting is that both "aaaaa" and "bbbbb" should shown twice,
> how can I achieve this?
>
> Looking forward for your reply,
>
>
>
>
>
>
>
> Thanks
>
> Vincent
>
>
>
>
--
--
David Weintraub
qazwart@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org