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 (http://jboss.sourceforge.net/snapshots/).  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."
                                 depends="init,rt">
    <calltarget target="${pkg_rt}"/>
  </target>

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

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

  &common;

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

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 (http://jakarta.apache.org/ant/faq.html#xml-entity-include).

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

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/buildmagic/tasks/src/main/org/jboss/tools/buildmagic/task/CallTarget.java

-----Original Message-----
From: PREMKUMAR, N [AG/8042] [mailto:n.premkumar@;monsanto.com]
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 ?

E.g:
 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. ?

Thanks,
Prem

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

Reply via email to