diff --git a/WHATSNEW b/WHATSNEW
index 3cc6bd1d5..eef76efc8 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -46,6 +46,8 @@ specified.
all files if the stylesheet changes.
* New data types fileset and patternset - expected to get a broader use.
+They as well as PATH like structures can now be defined on a global
+level and later be referenced by their id attribute.
* You can specify environment variables to .
diff --git a/build.xml b/build.xml
index 6ad623a0f..f51a8fe9f 100644
--- a/build.xml
+++ b/build.xml
@@ -34,6 +34,15 @@
+
+
+
+
+
+
+
+
+
@@ -125,10 +134,7 @@
-
-
-
-
+
diff --git a/docs/index.html b/docs/index.html
index 36bb2743f..87c1d70cc 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -460,6 +460,11 @@ defined.
Builds a PATH which holds the value of ${classpath}
followed by all JAR files in the lib
directory, followed
by the classes
directory.
+If you want to use the same PATH like structure for several tasks,
+you can define them with a <path>
element at the
+same level as targets and reference them via their
+id attribute - see References for an
+example.
Several tasks take arguments that shall be passed to another
@@ -518,33 +523,49 @@ the same snippet of XML over and over again - using a
example.
The following example
-<rmic ...>
- <classpath>
- <pathelement location="lib/" />
- <pathelement path="${java.class.path}/" />
- <pathelement path="${additional.path}" />
- </classpath>
-</rmic>
-<javac ...>
- <classpath>
- <pathelement location="lib/" />
- <pathelement path="${java.class.path}/" />
- <pathelement path="${additional.path}" />
- </classpath>
-</javac>
+<project ... >
+ <target ... >
+ <rmic ...>
+ <classpath>
+ <pathelement location="lib/" />
+ <pathelement path="${java.class.path}/" />
+ <pathelement path="${additional.path}" />
+ </classpath>
+ </rmic>
+ </target>
+
+ <target ... >
+ <javac ...>
+ <classpath>
+ <pathelement location="lib/" />
+ <pathelement path="${java.class.path}/" />
+ <pathelement path="${additional.path}" />
+ </classpath>
+ </javac>
+ </target>
+</project>
could be rewritten as
-<rmic ...>
- <classpath id="project.class.path">
+<project ... >
+ <path id="project.class.path">
<pathelement location="lib/" />
<pathelement path="${java.class.path}/" />
<pathelement path="${additional.path}" />
- </classpath>
-</rmic>
-<javac ...>
- <classpathref refid="project.class.path" />
-</javac>
+ </path>
+
+ <target ... >
+ <rmic ...>
+ <classpathref refid="project.class.path" />
+ </rmic>
+ </target>
+
+ <target ... >
+ <javac ...>
+ <classpathref refid="project.class.path" />
+ </javac>
+ </target>
+</project>
All tasks that use nested elements for PatternSets, FileSets or
@@ -666,9 +687,10 @@ If you do not want these default excludes applied, you may disable them with the
Patterns can be grouped to sets and later be referenced by their id
attribute. They are defined via a patternset
element -
-which can currently only appear nested into a FileSet or a directory based task that constitutes
-an implicit FileSet.
+which can appear nested into a FileSet or a
+directory based task that constitutes an implicit FileSet. In addition
+patternset
s can be defined at the same level as
+target
- i.e. as children of project
Patterns can be specified by nested <include>
or
<exclude>
elements or the following attributes.
@@ -713,8 +735,9 @@ can be referred to via
FileSets are groups of files. These files can be found in a
directory tree starting in a base directory and are matched by
patterns taken from a number of PatternSets. Currently FileSets can only appear
-inside task that support this feature.
+href="#patternset">PatternSets. FileSets can appear inside task
+that support this feature or at the same level as target
+- i.e. as children of project
.
PatternSets can be specified as nested
<patternset>
or <patternsetref>
elements. In addition FileSet holds an implicit PatternSet and
diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java
index 6a53770fe..87f441a74 100644
--- a/src/main/org/apache/tools/ant/ProjectHelper.java
+++ b/src/main/org/apache/tools/ant/ProjectHelper.java
@@ -250,6 +250,8 @@ public class ProjectHelper {
handleProperty(name, attrs);
} else if (name.equals("target")) {
handleTarget(name, attrs);
+ } else if (project.getDataTypeDefinitions().get(name) != null) {
+ handleDataType(name, attrs);
} else {
throw new SAXParseException("Unexpected element \"" + name + "\"", locator);
}
@@ -266,6 +268,10 @@ public class ProjectHelper {
private void handleTarget(String tag, AttributeList attrs) throws SAXParseException {
new TargetHandler(this).init(tag, attrs);
}
+
+ private void handleDataType(String name, AttributeList attrs) throws SAXParseException {
+ new DataTypeHandler(this).init(name, attrs);
+ }
}
/**
@@ -388,8 +394,6 @@ public class ProjectHelper {
* Handler for all nested properties.
*/
private class NestedElementHandler extends AbstractHandler {
- private DocumentHandler parentHandler;
-
private Object target;
private Object child;
@@ -431,6 +435,48 @@ public class ProjectHelper {
}
}
+ /**
+ * Handler for all data types at global level.
+ */
+ private class DataTypeHandler extends AbstractHandler {
+ private Object element;
+
+ public DataTypeHandler(DocumentHandler parentHandler) {
+ super(parentHandler);
+ }
+
+ public void init(String propType, AttributeList attrs) throws SAXParseException {
+ try {
+ element = project.createDataType(propType);
+ if (element == null) {
+ throw new BuildException("Unknown data type "+propType);
+ }
+
+ configure(element, attrs);
+ } catch (BuildException exc) {
+ throw new SAXParseException(exc.getMessage(), locator, exc);
+ }
+ }
+
+ public void characters(char[] buf, int start, int end) throws SAXParseException {
+ String text = new String(buf, start, end).trim();
+ if (text.length() == 0) return;
+
+ IntrospectionHelper ih =
+ IntrospectionHelper.getHelper(element.getClass());
+
+ try {
+ ih.addText(element, text);
+ } catch (BuildException exc) {
+ throw new SAXParseException(exc.getMessage(), locator, exc);
+ }
+ }
+
+ public void startElement(String name, AttributeList attrs) throws SAXParseException {
+ new NestedElementHandler(this, element).init(name, attrs);
+ }
+ }
+
private void configure(Object target, AttributeList attrs) throws BuildException {
if( target instanceof TaskAdapter )
target=((TaskAdapter)target).getProxy();
diff --git a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
index edaf4b008..0f4cc9c54 100644
--- a/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
+++ b/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
@@ -106,7 +106,8 @@ public class AntStructure extends Task {
out = new PrintWriter(new FileWriter(output));
}
- printHead(out);
+ Enumeration dataTypes = project.getDataTypeDefinitions().keys();
+ printHead(out, dataTypes);
Vector tasks = new Vector();
Enumeration enum = project.getTaskDefinitions().keys();
@@ -116,6 +117,13 @@ public class AntStructure extends Task {
}
printTargetDecl(out, tasks);
+ dataTypes = project.getDataTypeDefinitions().keys();
+ while (dataTypes.hasMoreElements()) {
+ String typeName = (String) dataTypes.nextElement();
+ printElementDecl(out, typeName,
+ (Class) project.getDataTypeDefinitions().get(typeName));
+ }
+
for (int i=0; i");
out.println("");
out.println("");
- out.println("");
+ out.print("");
out.println("