ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Murray, Mike B." <>
Subject RE: Design Pattern in Ant - Template Method
Date Mon, 11 Nov 2002 14:08:34 GMT
You have to make use of property values to direct an abstract target to an implementation of
it.  You cannot use the properties to create dynamic depends though.  You need to make use
of antcall, which has its drawbacks (creates new project instance, memory overhead), or use
a lighter version of it that is available with JBoss Build Magic (
 That is how I created the calltarget task, used below. 

Abstract Level:
  <property name="pkg_rt"        value="common.pkg_rt"/>

  <target name="pkg_rt"          description="Create the runtime archive."
    <calltarget target="${pkg_rt}"/>

  <target name="common.pkg_rt">
    no-op, or default implementation...

Concrete Level:
  <property name="pkg_rt"        value="my.pkg_rt"/>


  <target name="my.pkg_rt">
    concrete implementation...

You just need to manage the order of property value definitions, since a property will only
be assigned a value one time.  This is done by using entity includes at the proper time (

CallTarget is a fairly stand-alone task, so it should be easy to modify the code and make
it your own, if you prefer.

-----Original Message-----
From: PREMKUMAR, N [AG/8042] []
Sent: Monday, November 11, 2002 1:10 AM
To: 'Ant Users List'
Subject: Design Pattern in Ant - Template Method

Hi :

 I want to implement template-method design pattern in master-ant build file.. is it possible

 an ant-task in the master build file.. which on invocation will call "approptiate-tasks"
in a particular order.. the "appropriate-task" described in the master build file would be
abstract .. and the concrete implementation would be in the actual project-build-files.

Also I want to know if there is any equivalent of super()  ... for a given task .. so that
the task in the master will be executed before the child task executes. ?


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

View raw message