--- Steve Loughran <[EMAIL PROTECTED]> wrote:

> query wrote:
> > Earlier I was using some other build tool to build
> my project. Here if a target is built and if the
> same target is used to build some other target, it
> compares the timestamp and will not build the
> dependent targets again.
> 
> Ant doesnt compare the timestamps on targets, but it
> looks at the 
> timestamp of artifacts consumed and created by
> tasks. e.g  <javac> does 
> work only if there is java source to compile, but
> the <javac> task is 
> called on every build.

Note that this behavior can only be expected on a
per-task basis.  Some tasks, especially optional or
third-party tasks, may not perform any or the expected
dependency analysis.

> 
> > As I started working on ANT, I found it very
> useful and intersting. 
> 
> But in ANT, while building each target, it will try
> to build all the 
> dependent targets that many times as it occurs in
> different targets.
> 
> As a result it is increasing project\'s build
> time.Is there any task to 
> ensure that the dependent targets once built will
> not&nbsp; be built 
> again ????
> 
> Every target in a build file should run once. if the
> same targets run 
> again and again in a single build, your are using
> <ant> when you dont 
> need to. Every task in a target should do its own
> dependency rules, 
> though some <javadoc> dont. You can use <uptodate>
> to determine if 
> targets need skipping
> 

The other case in which you would re-run targets is if
you have several targets, all of which depend on some
initializing or similar target, e.g.:

target name="foo" depends="init"
target name="bar" depends="init"

'ant foo bar' will run init, foo, init, bar .  There
are a few workarounds here:

 - The old standard IMHO was to set a property in the
init target and name this property in init's unless
attribute:

<target name="init" unless="init.complete">
  ...
  <property name="init.complete" value="any value" />
</target>

 - Another approach is to make another target that
calls both the other targets:

target name="foobar" depends="foo,bar"

'ant foobar' will then execute init, foo, bar. 
Obviously this could get messy depending on how many
"first-class" targets you may have.

 - More recently Ant was augmented with the notion of
a Project Executor.  An implementation is provided
OOTB that will "pretend" there is a target described
like target "foobar" above.  It is called the single
check executor and you can invoke it thus:

ant
-Dant.executor.class=org.apache.tools.ant.helper.SingleCheckExecutor
foo bar

The Executor will run targets init, foo, bar by virtue
of its having used a single dependency check to
generate the call graph for all called targets.

Finally, If you are using the <ant> and/or <antcall>
tasks (which I personally discourage, but there you
are) you can call multiple targets by specifying
nested <target> elements in these tasks.  This will
make your <ant>/<antcall> invocation (1) use a
SingleCheckExecutor (unless, in theory, some top-level
custom executor was configured otherwise for
subprojects) and (2) use less time and resources
because you're only running one subproject instead of
n (where n = number of targets called).

HTH,
Matt

> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to