I use <antcall> when I have the same actions that need to be done on
different sets of files. For example:
<target name="genParser" depends="chkParser" unless="parser.done">
<echo message=" ${msg}"/>
<delete>
<fileset dir="${directory}" includes="${rmfiles}"/>
</delete>
<java classname="COM.sun.labs.javacc.Main"
classpath="${jjpath}"
dir="${directory}"
fork="yes"
failonerror="true">
<arg value="${jjfile}"/>
</java>
</target>
<target name="chkParser">
<uptodate property="parser.done"
targetfile="${directory}/${chkfile}" >
<srcfiles dir="${directory}" includes="${jjfile}" />
</uptodate>
</target>
Doing it this way not only saves on duplicating the same code over and
over, but since it's always run as either an <antcall> or an <ant>, I
don't have to worry about my "done" property getting set and staying set.
If I didn't do it this way, I'd have to come up with a different target
name for each parser-generating target, which in turn would each need
their own up-to-date-checking target, with their own "done" property. Ugh.
Diane
--- "O'Hara, Patrick" <[EMAIL PROTECTED]> wrote:
> Many people have said that depends is better. In general I agree, but
> there
> is one case where you might think you need antcall, that I would like to
> address. If you have a target such as:
> <target name="complex">
> <!-- Do Some processing -->
> <antcall target="some common functionality"/>
> <!-- Do Some more processing -->
> </target>
>
> You might think you need antcall for this. It would be easy to break
> this
> into three dependent targets, like:
>
> <target name="simple1">
> <!-- Do Some processing -->
> </target>
> <target name="some common functionality">
> <!-- Do Some common processing -->
> </target>
> <target name="simple2" depends="simple1, some common functionality">
> <!-- Do Some more processing -->
> </target>
>
> The result leaves me wondering what the purpose of antcall is?
>
> Patrick O'Hara
> 262-408-3849
> [EMAIL PROTECTED]
>
>
>
> -----Original Message-----
> From: Kyle Adams [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 28, 2001 8:39 AM
> To: [EMAIL PROTECTED]
> Subject: depends vs. antcall
>
>
> I've seen both the depends attribute of the target tag, and the antcall
> task
> used in very similar methods - to call internal targets the comprise an
> external target. For example:
>
> <target name="all" depends="init, build, deploy, clean">
> </target>
>
> vs.
>
> <target name="all">
> <antcall target="init" />
> <antcall target="build" />
> <antcall target="deploy" />
> <antcall target="clean" />
> </target>
>
> I've also seen this for the deploy target (to make jar, war, and ear
> files),
> for the build target (to make directories, compile). My question -
> which is
> the better way of doing this?
>
> Kyle
>
=====
([EMAIL PROTECTED])
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/