ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony LaPaso" <tlap...@attbi.com>
Subject Re: ?? A Clean-Up Task that Always Runs ??
Date Fri, 21 Jun 2002 01:23:22 GMT
Good-God man! That's hideous!



----- Original Message -----
From: "Geoff Meakin" <geoffm@isocra.com>
To: "Ant Users List" <ant-user@jakarta.apache.org>
Sent: Thursday, June 20, 2002 4:33 AM
Subject: RE: ?? A Clean-Up Task that Always Runs ??


> Here's a really ugly way to do it, assuming you want to contain
the whole
> thing within ANT- but see comments at the bottom-
>
> Existing build file #1.
> Write your cleanupTask in a different build file (#2). Write a
task in #2
> which calls the specified task
> in the ant build file #1, (using <ant>) after which it calls
your
> cleanupTask (using <antcall>).
> Call ant against build file #2 instead of build file #1.
> Note you could do these in the same buildfile and use <antcall>
all the
> time, except- since you want
> cleanupTask to *always* be executed, no matter what tasks are
specified at
> the commandline, it gives
> you the advantage of creating stub tasks in #2 (equivalents of
your #1
> tasks) which e.g. set a property
> and then call cleanupTask- which you couldn't do in just one
buildfile.
> Hey, I said it was really ugly!!! example below.
>
> #1
> <task name="myTask1">
>   do whatever...
> </task>
>
> <task name="myTask2">
>   do whatever...
> </task>
>
> #2
> <task name="default">
>   <property name="stub" value="default_task_in_#1"><and><equals
> arg1="${stub}" arg2="$${stub}"/></and></property>
>   <ant antfile="#1.xml" target="${stub}"/>
>   <antcall target="cleanupTask"/>
> </task>
>
> <task name="cleanupTask">
>   do cleanup...
> </task>
>
> <task name="myTask1">
>   <property name="stub" value="myTask1"/>
>   <antcall target="default"/>
> </task>
>
> <task name="myTask2">
>   <property name="stub" value="myTask2"/>
>   <antcall target="default"/>
> </task>
>
> ===
> If you dont want the horrible stub/ duplication of tasks, you
could pass the
> flag -Dtask=myTask1, instead, and
> modify the #2 buildfile accordingly, but that depends on your
needs.
>
> Though to be quite honest, I'd just create an alias/shell
script/batch
> script at the command-line level and then call the cleanupTask
as the last
> part of the alias, rather than all this horrible duplication,
as it seems
> the
> most sensible method unless you're using ANT integrated in some
IDE or
> whatever.
>
> Sorry, that wasn't a whole lot of help :)
>
> -Geoff
>
>
> --
> To unsubscribe, e-mail:
<mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:ant-user-help@jakarta.apache.org>
>
>


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


Mime
View raw message