ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoff Meakin" <>
Subject RE: ?? A Clean-Up Task that Always Runs ??
Date Thu, 20 Jun 2002 09:33:47 GMT
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.

<task name="myTask1">
  do whatever...

<task name="myTask2">
  do whatever...

<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 name="cleanupTask">
  do cleanup...

<task name="myTask1">
  <property name="stub" value="myTask1"/>
  <antcall target="default"/>

<task name="myTask2">
  <property name="stub" value="myTask2"/>
  <antcall target="default"/>

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
most sensible method unless you're using ANT integrated in some IDE or

Sorry, that wasn't a whole lot of help :)


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message