well. Reported by: Jose Alberto Fernandez <JFernandez@viquity.com> <ant> now checks it isn't calling the target it is nested into. Submitted by: Nico Seessle <nico@seessle.de> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268014 13f79535-47bb-0310-9956-ffa450edef68master
@@ -324,5 +324,9 @@ | |||||
</junit> | </junit> | ||||
</target> | </target> | ||||
<target name="testcall"> | |||||
<antcall target="testcall" /> | |||||
</target> | |||||
</project> | </project> | ||||
@@ -5000,11 +5000,11 @@ output. | |||||
registers a reference to this newly created task - at parser | registers a reference to this newly created task - at parser | ||||
time.</li> | time.</li> | ||||
<li><code>init()</code> is called at parser time.</li> | |||||
<li>The task gets a reference to the target it belongs to via its | <li>The task gets a reference to the target it belongs to via its | ||||
inherited <code>target</code> variable.</li> | inherited <code>target</code> variable.</li> | ||||
<li><code>init()</code> is called at parser time.</li> | |||||
<li>All child elements of the XML element corresponding to this task | <li>All child elements of the XML element corresponding to this task | ||||
are created via this task's <code>createXXX()</code> methods or | are created via this task's <code>createXXX()</code> methods or | ||||
instantiated and added to this task via its <code>addXXX()</code> | instantiated and added to this task via its <code>addXXX()</code> | ||||
@@ -377,15 +377,16 @@ public class ProjectHelper { | |||||
task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); | task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); | ||||
configureId(task, attrs); | configureId(task, attrs); | ||||
task.init(); | |||||
// Top level tasks don't have associated targets | // Top level tasks don't have associated targets | ||||
if (target != null) { | if (target != null) { | ||||
task.setOwningTarget(target); | task.setOwningTarget(target); | ||||
target.addTask(task); | target.addTask(task); | ||||
task.init(); | |||||
wrapper = task.getRuntimeConfigurableWrapper(); | wrapper = task.getRuntimeConfigurableWrapper(); | ||||
wrapper.setAttributes(attrs); | wrapper.setAttributes(attrs); | ||||
} else { | } else { | ||||
task.init(); | |||||
configure(task, attrs, project); | configure(task, attrs, project); | ||||
task.execute(); | task.execute(); | ||||
} | } | ||||
@@ -141,9 +141,17 @@ public class Ant extends Task { | |||||
p1.addTaskDefinition(taskName, taskClass); | 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 | // set user-define properties | ||||
Hashtable prop1 = project.getProperties(); | Hashtable prop1 = project.getProperties(); | ||||
Enumeration e = prop1.keys(); | |||||
e = prop1.keys(); | |||||
while (e.hasMoreElements()) { | while (e.hasMoreElements()) { | ||||
String arg = (String) e.nextElement(); | String arg = (String) e.nextElement(); | ||||
String value = (String) prop1.get(arg); | String value = (String) prop1.get(arg); | ||||
@@ -190,6 +198,14 @@ public class Ant extends Task { | |||||
target = p1.getDefaultTarget(); | 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); | p1.executeTarget(target); | ||||
} finally { | } finally { | ||||
// help the gc | // help the gc | ||||