From 510f6b08f62143dee0fa468e9c659ccec0562589 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig Concepts
-
No
-
@@ -225,11 +225,11 @@
don't use Ants main class as entry point and calling them from the IDE
is usually possible.group
+ extensionOf
Adds the current target to the depends list of
- the named target-group.
+ the named extension-point.
since Ant 1.8.0.
No
since Ant 1.8.0.
-Target-Groups are similar to targets in that they have a name and +
Extension-Points are similar to targets in that they have a name and a depends list and can be executed from the command line. Just like targets they represent a state during the build process.
@@ -237,18 +237,18 @@ is to collect targets that contribute to the desired state in their depends list. -Targets can add themselves to a target-group's depends list via - their group attribute. The targets that add themselves will be +
Targets can add themselves to an extension-points's depends list via + their extensionOf attribute. The targets that add themselves will be added after the targets of the explicit depends-attribute of the - target-group, if multiple targets add themselves, their relative + extension-point, if multiple targets add themselves, their relative order is not defined.
-The main purpose of a target-group is to act as an extension +
The main purpose of an extension-point is to act as an extension point for build files designed to be imported. In the imported - file a target-groups defines a state that must be reached and + file an extension-point defines a state that must be reached and targets from other build files can join the depends list of said - target-group in order to contribute to that state.
+ extension-point in order to contribute to that state.For example your imported build file may need to compile code, it might look like:
@@ -256,7 +256,7 @@ <target name="create-directory-layout"> ... </target> -<target-group name="ready-to-compile" +<extension-point name="ready-to-compile" depends="create-directory-layout"/> <target name="compile" depends="ready-to-compile"> ... @@ -270,7 +270,7 @@ your main build file you may use something likediff --git a/src/main/org/apache/tools/ant/TargetGroup.java b/src/main/org/apache/tools/ant/ExtensionPoint.java similarity index 85% rename from src/main/org/apache/tools/ant/TargetGroup.java rename to src/main/org/apache/tools/ant/ExtensionPoint.java index 1e2b4aaf2..bc0f35b50 100644 --- a/src/main/org/apache/tools/ant/TargetGroup.java +++ b/src/main/org/apache/tools/ant/ExtensionPoint.java @@ -18,17 +18,18 @@ package org.apache.tools.ant; /** - * A special kind of target that must be empty. + * An extension point build files can provide as a place where other + * build files can add new dependencies. * * @since Ant 1.8.0 */ -public class TargetGroup extends Target { +public class ExtensionPoint extends Target { // no "clone" constructor since I'm not really sure where it is // used private static final String NO_CHILDREN_ALLOWED - = "you must not nest child elements into a target-group"; + = "you must not nest child elements into an extension-point"; /** * Throws an exception. diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java index 5c3a1667a..3d16716e6 100644 --- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java +++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java @@ -18,13 +18,13 @@ package org.apache.tools.ant.helper; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.ExtensionPoint; import org.apache.tools.ant.Location; import org.apache.tools.ant.MagicNames; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import org.apache.tools.ant.RuntimeConfigurable; import org.apache.tools.ant.Target; -import org.apache.tools.ant.TargetGroup; import org.apache.tools.ant.Task; import org.apache.tools.ant.UnknownElement; import org.apache.tools.ant.types.Resource; @@ -825,19 +825,19 @@ public class ProjectHelper2 extends ProjectHelper { * @exception org.xml.sax.SAXParseException if the tag given is not *<target name="generate-sources" - group="ready-to-compile"> + extensionOf="ready-to-compile"> ... </target>
"taskdef"
, "typedef"
,
* "property"
, "target"
,
- * "target-group"
+ * "extension-point"
* or a data type definition
*/
public AntHandler onStartChild(String uri, String name, String qname, Attributes attrs,
AntXMLContext context) throws SAXParseException {
- return (name.equals("target") || name.equals("target-group"))
+ return (name.equals("target") || name.equals("extension-point"))
&& (uri.equals("") || uri.equals(ANT_CORE_URI))
? ProjectHelper2.targetHandler : ProjectHelper2.elementHandler;
}
}
/**
- * Handler for "target" and "target-group" elements.
+ * Handler for "target" and "extension-point" elements.
*/
public static class TargetHandler extends AntHandler {
@@ -865,11 +865,11 @@ public class ProjectHelper2 extends ProjectHelper {
AntXMLContext context) throws SAXParseException {
String name = null;
String depends = "";
- String targetGroup = null;
+ String extensionPoint = null;
Project project = context.getProject();
Target target = "target".equals(tag)
- ? new Target() : new TargetGroup();
+ ? new Target() : new ExtensionPoint();
target.setProject(project);
target.setLocation(new Location(context.getLocator()));
context.addTarget(target);
@@ -899,8 +899,8 @@ public class ProjectHelper2 extends ProjectHelper {
}
} else if (key.equals("description")) {
target.setDescription(value);
- } else if (key.equals("target-group")) {
- targetGroup = value;
+ } else if (key.equals("extensionOf")) {
+ extensionPoint = value;
} else {
throw new SAXParseException("Unexpected attribute \"" + key + "\"", context
.getLocator());
@@ -969,9 +969,9 @@ public class ProjectHelper2 extends ProjectHelper {
context.getCurrentTargets().put(newName, newTarget);
project.addOrReplaceTarget(newName, newTarget);
}
- if (targetGroup != null) {
+ if (extensionPoint != null) {
for (Iterator iter =
- Target.parseDepends(targetGroup, name, "target-group")
+ Target.parseDepends(extensionPoint, name, "extensionOf")
.iterator();
iter.hasNext(); ) {
String tgName = (String) iter.next();
@@ -980,16 +980,16 @@ public class ProjectHelper2 extends ProjectHelper {
}
if (!projectTargets.containsKey(tgName)) {
throw new BuildException("can't add target "
- + name + " to target-group "
+ + name + " to extension-point "
+ tgName
- + " because the target-group"
+ + " because the extension-point"
+ " is unknown.");
}
Target t = (Target) projectTargets.get(tgName);
- if (!(t instanceof TargetGroup)) {
+ if (!(t instanceof ExtensionPoint)) {
throw new BuildException("referenced target "
+ tgName
- + " is not a target-group");
+ + " is not an extension-point");
}
t.addDependency(name);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
index 5fa927644..5468305b0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
@@ -229,7 +229,7 @@ public class AntStructure extends Task {
out.println("");
- out.print("");
out.println("");
printTargetAttrs(out, "target");
- out.println("");
+ out.println("");
out.println("");
- printTargetAttrs(out, "target-group");
+ printTargetAttrs(out, "extension-point");
}
/**
@@ -268,7 +268,7 @@ public class AntStructure extends Task {
out.println(" if CDATA #IMPLIED");
out.println(" unless CDATA #IMPLIED");
out.println(" depends CDATA #IMPLIED");
- out.println(" target-group CDATA #IMPLIED");
+ out.println(" extensionOf CDATA #IMPLIED");
out.println(" description CDATA #IMPLIED>");
out.println("");
}
diff --git a/src/tests/antunit/core/target-group-test.xml b/src/tests/antunit/core/extension-point-test.xml
similarity index 74%
rename from src/tests/antunit/core/target-group-test.xml
rename to src/tests/antunit/core/extension-point-test.xml
index b098c80bf..012375c09 100644
--- a/src/tests/antunit/core/target-group-test.xml
+++ b/src/tests/antunit/core/extension-point-test.xml
@@ -19,7 +19,7 @@