diff --git a/build.xml b/build.xml index d136706a8..0d4b7bbad 100644 --- a/build.xml +++ b/build.xml @@ -324,5 +324,9 @@ + + + + diff --git a/docs/index.html b/docs/index.html index 6d6755783..4f831851d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5000,11 +5000,11 @@ output. registers a reference to this newly created task - at parser time. -
  • init() is called at parser time.
  • -
  • The task gets a reference to the target it belongs to via its inherited target variable.
  • +
  • init() is called at parser time.
  • +
  • All child elements of the XML element corresponding to this task are created via this task's createXXX() methods or instantiated and added to this task via its addXXX() diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index a6616c57e..3578b2718 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -377,15 +377,16 @@ public class ProjectHelper { task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); configureId(task, attrs); - task.init(); // Top level tasks don't have associated targets if (target != null) { task.setOwningTarget(target); target.addTask(task); + task.init(); wrapper = task.getRuntimeConfigurableWrapper(); wrapper.setAttributes(attrs); } else { + task.init(); configure(task, attrs, project); task.execute(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index 2634e5b52..b889bd0a3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -141,9 +141,17 @@ public class Ant extends Task { p1.addTaskDefinition(taskName, taskClass); } + Hashtable typedefs = project.getDataTypeDefinitions(); + Enumeration e = typedefs.keys(); + while (e.hasMoreElements()) { + String typeName = (String) e.nextElement(); + Class typeClass = (Class) typedefs.get(typeName); + p1.addDataTypeDefinition(typeName, typeClass); + } + // set user-define properties Hashtable prop1 = project.getProperties(); - Enumeration e = prop1.keys(); + e = prop1.keys(); while (e.hasMoreElements()) { String arg = (String) e.nextElement(); String value = (String) prop1.get(arg); @@ -190,6 +198,14 @@ public class Ant extends Task { target = p1.getDefaultTarget(); } + // Are we trying to call the target in which we are defined? + if (p1.getBaseDir().equals(project.getBaseDir()) && + p1.getProperty("ant.file").equals(project.getProperty("ant.file")) && + target.equals(this.getOwningTarget().getName())) { + + throw new BuildException("ant task calling it's own parent target"); + } + p1.executeTarget(target); } finally { // help the gc