ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aslak Helles√ły <>
Subject Dynamic createBlaBla methods in Ant tasks using BCEL at runtime
Date Thu, 25 Apr 2002 23:27:32 GMT
Hi Erik, Ant, XDoclet. (I'm crossposting, and I'm not subscribed to ant-dev,
so if you want to reach me, please mail me personally or to xdoclet-devel).

This is a follow up to some mails Erik Hatcher and Ara Abrahamian (XDoclet
admin) posted to ant-dev some weeks ago.

I think I know how you (Ant) can incorporate the dynamic BCEL/createBlaBla
generation in tasks in the Ant core.
We're already doing this in XDoclet and are using it for dynamic modules
where we don't know at compile-time what
aub-elements a task will have.

You'll have to add

   private final Vector subTasks = new Vector(); // You're trying to avoid
the java.util.List aren't you ;-)

   protected void addSubTask(Object o) {

   protected List/Vector getSubTasks() {
      return _subTasks;


If all ant modules have a deployment descriptor (which they do, don't they?)
have a section à la


for all classes intended to be used as subtasks you should have all the info
you need.
We use xdoclet to generate these deployment descriptors for our own plugins.
The BCEL-savvy class-loader will insert a method like this

   public com.aslak.AslakServerSubTask createAslak() {
      com.aslak.AslakServerSubTask = new com.aslak.AslakServerSubTask();
      return subTask;


Currently we are in XDoclet generating slightly different and a bit more
fragile code:

   public com.aslak.AslakServerSubTask createAslak() {
      com.aslak.AslakServerSubTask = new com.aslak.AslakServerSubTask();
      return subTask;

-so the BCEL juggling would be a bit modified from what you'll find inside
but this is something you should definitely consider adding to the Ant core.

Do you think this could work for you? Feel free to steal/improve the code
under xdoclet.loader

Thanks for a great product! (You probably don't hear that too often. People
must be taking you for granted now ;-)


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

View raw message