You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Issam Aib <ia...@bbcr.uwaterloo.ca> on 2006/02/05 05:58:18 UTC

Ant task : how to avoid re-executing the same task

Hi all,

If you are in a hurry and want to help me too, the question is at paragraph 6, thanks.

I use an <import/> task to import global properties for each ant script of a project. 
When debugging through the ant scripts I notice that each time the import statement goes through all of the import file. This is not harmful but this slows down the build time. The problem is more severe when calling <ant..> tasks involving a bunch of javac and other sub <ant ..> task calls… the result is that some tasks get called a kind of ten times or more.

Here is a simple example to understand me:
Task build in script sa.xml does some actions like compiling the directory where sa.xml resides.
Task build in script sb.xml does something alike for his directory but calls sa’s build beforehand.
Task build in script sc.xml calls build tasks of both sa.xml and sb.xml.
The main build script build.xml calls the build tasks of sa, sb, sc respectively.

The end of the story is that sa’s build task ends up being called three times while it just needs to be called once.

A possible solution is to call only sc’s build in the main build.xml and call only sb’s build in sc. However in a big project where there is a kind of complex hierarchy we need not to bother ourselves if for example sc’s build requires a’s build beforehand, so if we need both sc’s build and a’s build we just call them both to be safe.

**** The question ****
The question that arises is this one: Is there some ant structure which allows me to check if some task of a given ant script has already executed at least once during the current script execution, and if so it then gives you the choice whether to call the task again or just not to call it?

Thanks for helping ☺

Issam Aib


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


Re: Ant task : how to avoid re-executing the same task

Posted by glenn opdycke-hansen <gl...@gmail.com>.
If I understand correctly, I would set a property from the import 
target and then add an "unless" clause to the target.  If the target
is executed once, then it would not be executed again.
This approach may not work if the script is using "antcall" tasks,
though.  I would search for "antcall" and possibly rewrite.

--glenn

On 2/4/06, Issam Aib <ia...@bbcr.uwaterloo.ca> wrote:
> Hi all,
>
> If you are in a hurry and want to help me too, the question is at paragraph 6, thanks.
>
> I use an <import/> task to import global properties for each ant script of a project.
> When debugging through the ant scripts I notice that each time the import statement goes through all of the import file. This is not harmful but this slows down the build time. The problem is more severe when calling <ant..> tasks involving a bunch of javac and other sub <ant ..> task calls… the result is that some tasks get called a kind of ten times or more.
>
> Here is a simple example to understand me:
> Task build in script sa.xml does some actions like compiling the directory where sa.xml resides.
> Task build in script sb.xml does something alike for his directory but calls sa's build beforehand.
> Task build in script sc.xml calls build tasks of both sa.xml and sb.xml.
> The main build script build.xml calls the build tasks of sa, sb, sc respectively.
>
> The end of the story is that sa's build task ends up being called three times while it just needs to be called once.
>
> A possible solution is to call only sc's build in the main build.xml and call only sb's build in sc. However in a big project where there is a kind of complex hierarchy we need not to bother ourselves if for example sc's build requires a's build beforehand, so if we need both sc's build and a's build we just call them both to be safe.
>
> **** The question ****
> The question that arises is this one: Is there some ant structure which allows me to check if some task of a given ant script has already executed at least once during the current script execution, and if so it then gives you the choice whether to call the task again or just not to call it?
>
> Thanks for helping ☺
>
> Issam Aib
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>


--

--glenn