Sam,
could you please try the attached patch? It is far from perfect and
won't help with tasks that are inside "TaskContainer"s but is a first
cut.
I cannot find a sensible way to replace existing task objects inside
TaskContainers without adding a getTasks method to TaskContainer,
which I wouldn't like to do. Others?
Stefan
Index: src/main/org/apache/tools/ant/Target.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Target.java,v
retrieving revision 1.29
diff -u -r1.29 Target.java
--- src/main/org/apache/tools/ant/Target.java 2001/12/12 09:17:36 1.29
+++ src/main/org/apache/tools/ant/Target.java 2001/12/13 16:17:11
@@ -178,11 +178,38 @@
public void execute() throws BuildException {
if (testIfCondition() && testUnlessCondition()) {
- Enumeration enum = children.elements();
- while (enum.hasMoreElements()) {
- Object o = enum.nextElement();
+ for (int i=0; i<children.size(); i++) {
+ Object o = children.elementAt(i);
if (o instanceof Task) {
Task task = (Task) o;
+
+ String elementName = task.taskType;
+ Class currentTaskClass = null;
+ if (o instanceof TaskAdapter) {
+ currentTaskClass = ((TaskAdapter)
o).getProxy().getClass();
+ } else {
+ currentTaskClass = task.getClass();
+ }
+
+ Class validTaskClass =
+ (Class) project.getTaskDefinitions().get(elementName);
+ if (!(o instanceof UnknownElement)
+ && !currentTaskClass.equals(validTaskClass)) {
+ project.log("replacing task "+elementName+" at
"+task.getLocation()+". Old class: "+currentTaskClass+", new class
"+validTaskClass,
+ Project.MSG_VERBOSE);
+
+ Task newTask = project.createTask(elementName);
+ newTask.setLocation(task.getLocation());
+ newTask.setOwningTarget(this);
+ children.setElementAt(newTask, i);
+ newTask.init();
+ RuntimeConfigurable wrapper =
+ task.getRuntimeConfigurableWrapper();
+ newTask.setRuntimeConfigurableWrapper(wrapper);
+ wrapper.setProxy(newTask);
+ task = newTask;
+ }
+
task.perform();
} else {
RuntimeConfigurable r = (RuntimeConfigurable) o;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>