Discussion:
AntCall vs depends style question
John Lindwall
2002-03-22 23:53:22 UTC
Permalink
I'm a oldtime make user who is now adjusting to ant (which I love BTW).

In make you use dependencies to enforce ordering of targets. You can do the same thing in ant using the "depends" attribute. In ant you can also directly invoke other ant targets using the "antcall" builtin task. The build files below are similar in that the "all" target causes "subtask" to be run and then "all"; one uses antcall the other uses depends. The "antcall" solution has the side-effect of unconditionally invoking all dependencies of "subtask" so in this example you see the "init" target invoked twice. However "antcall" is nice in that you can pass properties to the invoked target.

So I guess I'm just looking for best practice advice here. Do people avoid antcall? Use it a lot? As needed? I dislike the reinvocation of the "init" target but don't know how else to build a reusable target that can be invoked at oher points in the build file (with varying properties as arguments).

Thanks for your opinions!

<!-- START -->
<project name="antcall" default="all">

<target name="init">
<echo message="init task"/>
</target>

<target name="all" depends="init">
<antcall target="subtask"/>
<echo message="all task"/>
</target>

<target name="subtask" depends="init">
<echo message="subtask task"/>
</target>

</project>
<!-- END -->

<!-- START -->
<project name="depends" default="all">

<target name="init">
<echo message="init task"/>
</target>

<target name="all" depends="init,subtask">
<echo message="all task"/>
</target>

<target name="subtask" depends="init">
<echo message="subtask task"/>
</target>

</project>
<!-- END -->


------------------------------------------------------------------
John Lindwall mailto:***@xifin.com
XIFIN http://www.xifin.com
2233 Faraday Ave Ste A, Carlsbad CA 92008 (760) 804-0770 ext 16

This message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and destroy all copies of the original message.
Vishweshwar, Ghanakota
2002-03-23 00:01:18 UTC
Permalink
there are some differences in "antcall" and "depends". antcall can be called
from anywhere in the target whereas depends makes sure that the dependant
targets are run before this! as far as the "param" goes, your dependant
targets get the "param" too!

vishu
-----Original Message-----
Sent: Friday, March 22, 2002 3:53 PM
Subject: AntCall vs depends style question
I'm a oldtime make user who is now adjusting to ant (which I
love BTW).
In make you use dependencies to enforce ordering of targets.
You can do the same thing in ant using the "depends"
attribute. In ant you can also directly invoke other ant
targets using the "antcall" builtin task. The build files
below are similar in that the "all" target causes "subtask"
to be run and then "all"; one uses antcall the other uses
depends. The "antcall" solution has the side-effect of
unconditionally invoking all dependencies of "subtask" so in
this example you see the "init" target invoked twice.
However "antcall" is nice in that you can pass properties to
the invoked target.
So I guess I'm just looking for best practice advice here.
Do people avoid antcall? Use it a lot? As needed? I dislike
the reinvocation of the "init" target but don't know how else
to build a reusable target that can be invoked at oher points
in the build file (with varying properties as arguments).
Thanks for your opinions!
<!-- START -->
<project name="antcall" default="all">
<target name="init">
<echo message="init task"/>
</target>
<target name="all" depends="init">
<antcall target="subtask"/>
<echo message="all task"/>
</target>
<target name="subtask" depends="init">
<echo message="subtask task"/>
</target>
</project>
<!-- END -->
<!-- START -->
<project name="depends" default="all">
<target name="init">
<echo message="init task"/>
</target>
<target name="all" depends="init,subtask">
<echo message="all task"/>
</target>
<target name="subtask" depends="init">
<echo message="subtask task"/>
</target>
</project>
<!-- END -->
------------------------------------------------------------------
XIFIN http://www.xifin.com
2233 Faraday Ave Ste A, Carlsbad CA 92008 (760) 804-0770 ext 16
This message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please
contact the sender and destroy all copies of the original message.
"MMS <firstam.com>" made the following
annotations on 03/22/02 16:02:48
------------------------------------------------------------------------------
"THIS E-MAIL MESSAGE AND ANY FILES TRANSMITTED HEREWITH, ARE INTENDED SOLELY FOR THE USE OF THE INDIVIDUAL(S) ADDRESSED AND MAY CONTAIN CONFIDENTIAL, PROPRIETARY OR PRIVILEGED INFORMATION. IF YOU ARE NOT THE ADDRESSEE INDICATED IN THIS MESSAGE (OR RESPONSIBLE FOR DELIVERY OF THIS MESSAGE TO SUCH PERSON) YOU MAY NOT REVIEW, USE, DISCLOSE OR DISTRIBUTE THIS MESSAGE OR ANY FILES TRANSMITTED HEREWITH. IF YOU RECEIVE THIS MESSAGE IN ERROR, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE THIS MESSAGE AND ALL COPIES OF IT FROM YOUR SYSTEM."

==============================================================================


--
To unsubscribe, e-mail: <mailto:ant-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-***@jakarta.apache.org>
stephan beal
2002-03-23 15:49:35 UTC
Permalink
Post by John Lindwall
So I guess I'm just looking for best practice advice here. Do people avoid
antcall? Use it a lot? As needed? I dislike the reinvocation of the
"init" target but don't know how else to build a reusable target that can
be invoked at oher points in the build file (with varying properties as
arguments).
i had this same problem, but i was overusing antcall considerable. i worked
around the init-called-too-often with this:

<target name="init" unless='init.alreadydone'>
<property name='init.alreadydone' value='true'/>
...
</target>

----- ***@wanderinghorse.net
http://qub.sourceforge.net - http://radioaqtiph.sourceforge.net
http://www.countermoves.net - http://stephan.rootonfire.org
"All them women gonna make me teach 'em what they don't know how.
I'm going to Jackson." -- Johnny Cash




--
To unsubscribe, e-mail: <mailto:ant-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-***@jakarta.apache.org>
stephan beal
2002-03-23 15:49:35 UTC
Permalink
Post by John Lindwall
So I guess I'm just looking for best practice advice here. Do people avoid
antcall? Use it a lot? As needed? I dislike the reinvocation of the
"init" target but don't know how else to build a reusable target that can
be invoked at oher points in the build file (with varying properties as
arguments).
i had this same problem, but i was overusing antcall considerable. i worked
around the init-called-too-often with this:

<target name="init" unless='init.alreadydone'>
<property name='init.alreadydone' value='true'/>
...
</target>

----- ***@wanderinghorse.net
http://qub.sourceforge.net - http://radioaqtiph.sourceforge.net
http://www.countermoves.net - http://stephan.rootonfire.org
"All them women gonna make me teach 'em what they don't know how.
I'm going to Jackson." -- Johnny Cash




--
To unsubscribe, e-mail: <mailto:ant-user-***@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-***@jakarta.apache.org>
Loading...