bodewig 00/07/21 05:42:57
Modified: src/main/org/apache/tools/ant/taskdefs AntStructure.java
src/main/org/apache/tools/ant/types FileSet.java
Added: src/main/org/apache/tools/ant/types Reference.java
Log:
Added a nested patternsetref element to fileset.
Revision Changes Path
1.3 +12 -0
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java
Index: AntStructure.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/AntStructure.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AntStructure.java 2000/07/14 06:30:56 1.2
+++ AntStructure.java 2000/07/21 12:42:54 1.3
@@ -178,6 +178,16 @@
StringBuffer sb = new StringBuffer("<!ELEMENT ");
sb.append(name).append(" ");
+ if (org.apache.tools.ant.types.Reference.class.equals(element)) {
+ sb.append("EMPTY>").append(lSep);
+ sb.append("<!ATTLIST ").append(name);
+ sb.append(lSep).append(" id ID #IMPLIED");
+ sb.append(lSep).append(" refid IDREF #IMPLIED");
+ sb.append(">").append(lSep);
+ out.println(sb);
+ return;
+ }
+
Vector v = new Vector();
if (ih.supportsCharacters()) {
v.addElement("#PCDATA");
@@ -218,6 +228,8 @@
if (type.equals(java.lang.Boolean.class) ||
type.equals(java.lang.Boolean.TYPE)) {
sb.append("%boolean; ");
+ } else if
(org.apache.tools.ant.types.Reference.class.isAssignableFrom(type)) {
+ sb.append("IDREF ");
} else if
(org.apache.tools.ant.EnumeratedAttribute.class.isAssignableFrom(type)) {
try {
EnumeratedAttribute ea =
1.3 +37 -9
jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java
Index: FileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileSet.java 2000/07/19 16:00:53 1.2
+++ FileSet.java 2000/07/21 12:42:56 1.3
@@ -57,7 +57,9 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
+
import java.io.File;
+import java.util.Vector;
/**
* Moved out of MatchingTask to make it a standalone object that could
@@ -71,7 +73,8 @@
*/
public class FileSet {
- private PatternSet patterns = new PatternSet();
+ private PatternSet defaultPatterns = new PatternSet();
+ private Vector additionalPatterns = new Vector();
private File dir;
private boolean useDefaultExcludes = true;
@@ -95,21 +98,29 @@
}
public PatternSet createPatternSet() {
+ PatternSet patterns = new PatternSet();
+ additionalPatterns.addElement(patterns);
return patterns;
}
+ public Reference createPatternSetRef() {
+ Reference r = new Reference();
+ additionalPatterns.addElement(r);
+ return r;
+ }
+
/**
* add a name entry on the include list
*/
public PatternSet.NameEntry createInclude() {
- return patterns.createInclude();
+ return defaultPatterns.createInclude();
}
/**
* add a name entry on the exclude list
*/
public PatternSet.NameEntry createExclude() {
- return patterns.createExclude();
+ return defaultPatterns.createExclude();
}
/**
@@ -119,7 +130,7 @@
* @param includes the string containing the include patterns
*/
public void setIncludes(String includes) {
- patterns.setIncludes(includes);
+ defaultPatterns.setIncludes(includes);
}
/**
@@ -129,7 +140,7 @@
* @param excludes the string containing the exclude patterns
*/
public void setExcludes(String excludes) {
- patterns.setExcludes(excludes);
+ defaultPatterns.setExcludes(excludes);
}
/**
@@ -139,7 +150,7 @@
* the include patterns from.
*/
public void setIncludesfile(File incl) throws BuildException {
- patterns.setIncludesfile(incl);
+ defaultPatterns.setIncludesfile(incl);
}
/**
@@ -149,7 +160,7 @@
* the include patterns from.
*/
public void setExcludesfile(File excl) throws BuildException {
- patterns.setExcludesfile(excl);
+ defaultPatterns.setExcludesfile(excl);
}
/**
@@ -169,8 +180,25 @@
public DirectoryScanner getDirectoryScanner(Project p) {
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(dir);
- ds.setIncludes(patterns.getIncludePatterns(p));
- ds.setExcludes(patterns.getExcludePatterns(p));
+
+ for (int i=0; i<additionalPatterns.size(); i++) {
+ Object o = additionalPatterns.elementAt(i);
+ if (o instanceof PatternSet) {
+ defaultPatterns.append((PatternSet) o);
+ } else {
+ Reference r = (Reference) o;
+ o = r.getReferencedObject(p);
+ if (o instanceof PatternSet) {
+ defaultPatterns.append((PatternSet) o);
+ } else {
+ String msg = r.getRefId()+" doesn\'t denote a
patternset";
+ throw new BuildException(msg);
+ }
+ }
+ }
+
+ ds.setIncludes(defaultPatterns.getIncludePatterns(p));
+ ds.setExcludes(defaultPatterns.getExcludePatterns(p));
if (useDefaultExcludes) ds.addDefaultExcludes();
ds.scan();
return ds;
1.1
jakarta-ant/src/main/org/apache/tools/ant/types/Reference.java
Index: Reference.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.types;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
/**
* Named collection of include/exclude tags.
*
* <p>Class to hold a reference to another object in the project.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
*/
public class Reference {
private String refid;
public Reference() {
super();
}
public Reference(String id) {
this();
setRefId(id);
}
public void setRefId(String id) {
refid = id;
}
public String getRefId() {
return refid;
}
public Object getReferencedObject(Project project) throws BuildException {
if (refid == null) {
throw new BuildException("No reference specified");
}
Object o = project.getReferences().get(refid);
if (o == null) {
throw new BuildException("Refernce "+refid+" not found.");
}
return o;
}
}