Browse Source

<ant> now copies the definitions of data types to the child project as

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-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
7ee8e30cd0
4 changed files with 25 additions and 4 deletions
  1. +4
    -0
      build.xml
  2. +2
    -2
      docs/index.html
  3. +2
    -1
      src/main/org/apache/tools/ant/ProjectHelper.java
  4. +17
    -1
      src/main/org/apache/tools/ant/taskdefs/Ant.java

+ 4
- 0
build.xml View File

@@ -324,5 +324,9 @@
</junit>
</target>

<target name="testcall">
<antcall target="testcall" />
</target>

</project>


+ 2
- 2
docs/index.html View File

@@ -5000,11 +5000,11 @@ output.
registers a reference to this newly created task - at parser
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
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
are created via this task's <code>createXXX()</code> methods or
instantiated and added to this task via its <code>addXXX()</code>


+ 2
- 1
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -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();
}


+ 17
- 1
src/main/org/apache/tools/ant/taskdefs/Ant.java View File

@@ -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


Loading…
Cancel
Save