You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by query <se...@rediffmail.com> on 2007/05/24 13:46:03 UTC

Building Dependent targets

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.
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 ????

Re: Building Dependent targets

Posted by Matt Benson <gu...@yahoo.com>.
--- Steve Loughran <st...@apache.org> 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:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



 
____________________________________________________________________________________
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Building Dependent targets

Posted by Steve Loughran <st...@apache.org>.
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.

> 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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Building Dependent targets

Posted by Gilles Scokart <gs...@gmail.com>.
If you have multiple projects and you want to build them the right order, you
can also use ivy (http://incubator.apache.org/ivy/).  It's a dependency
managment tool having ant tasks to order a list of subproject according to
their respective dependencies
(http://incubator.apache.org/ivy/doc/use/buildlist.html).  It use a metadata
XML file to descibes the dependency of every module.  Ivy can also use this
file to do a lot of other thinks like definind classpaths or fileset, or
producing report.

Gilles


Doug Lochart-3 wrote:
> 
> Joe Schmetzer wrote:
>> On Thu, 24 May, 2007 12:46 pm, 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.
>>> 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 ????
>>>     
>>
>> If you're willing to reorganise you build targets into different
>> projects,
>> the technique described here can help:
>>
>> http://www.exubero.com/ant/dependencies.html
>>
>> HTH
>>   
> I like this approach.  I may look into adopting it.  I have projects 
> very segregated already so adopting this style should be easy and
> painless.
> 
> thanks
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Building-Dependent-targets-tf3809595.html#a10798131
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Building Dependent targets

Posted by Doug Lochart <dl...@capecomputing.com>.
Joe Schmetzer wrote:
> On Thu, 24 May, 2007 12:46 pm, 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.
>> 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 ????
>>     
>
> If you're willing to reorganise you build targets into different projects,
> the technique described here can help:
>
> http://www.exubero.com/ant/dependencies.html
>
> HTH
>   
I like this approach.  I may look into adopting it.  I have projects 
very segregated already so adopting this style should be easy and painless.

thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Building Dependent targets

Posted by Joe Schmetzer <jo...@exubero.com>.
On Thu, 24 May, 2007 12:46 pm, 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.
> 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 ????

If you're willing to reorganise you build targets into different projects,
the technique described here can help:

http://www.exubero.com/ant/dependencies.html

HTH
-- 
Joe Schmetzer .:. Renaissance Developer .:. http://www.exubero.com/
                   +44-(0)7775-770-422

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Building Dependent targets

Posted by David Weintraub <qa...@gmail.com>.
Two things:

Ant will show the task as being executed, but may not actually carry
out the task. For example, you may see a task <copy> being executed
when you have the debug flag on, but the copy itself might not be
done. Of course, a target will always be executed even if the tasks in
it don't have to be executed.

Some tasks (due to the way the task was programmed) will execute even
if it doesn't have to. For example, in old Weblogic bean creations,
the bean would be recreated even if the *.java files weren't modified.
To get around this problem look at the "uptodate" task. This task
allows you to set a property if a particular set of files have a
timestamp that's newer than a particular source file. Then, you can
define a target to run if the property is set or not set.

If you use the Ant Contrib tasks, you can use the "outofdate" task
which is very similar to the "uptodate" task, except that the
"outofdate" task allows you to define a set of tasks to execute when
the outofdate condition is met. These tasks can be run either
sequentially or in parallel.

See <http://ant-contrib.sourceforge.net/tasks/tasks/outofdate.html>
for information on the outofdate task and
<http://ant.apache.org/manual/CoreTasks/uptodate.html> for the
"uptodate" task. Remember that the "outofdate" task is only good if
you have the antcontrib tasks included in your task library.

On 24 May 2007 11:46:03 -0000, query <se...@rediffmail.com> 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.
> 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 ????


-- 
--
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org