bodewig 00/08/07 06:58:36
Modified: src/main/org/apache/tools/ant/taskdefs Java.java Javac.java
Javadoc.java Rmic.java
src/main/org/apache/tools/ant/types Commandline.java
Log:
Added nested elements and attributes to reference CLASSPATH structures
defined at another place in the same project.
Revision Changes Path
1.16 +47 -3
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
Index: Java.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Java.java 2000/08/01 10:25:58 1.15
+++ Java.java 2000/08/07 13:58:34 1.16
@@ -61,6 +61,7 @@
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
import java.io.File;
import java.io.IOException;
@@ -79,6 +80,7 @@
private boolean fork = false;
private File dir = null;
private boolean failOnError = false;
+ private Vector classpathReferences = new Vector();
/**
* Do the execution.
@@ -138,6 +140,22 @@
}
/**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void addClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void setClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
* Set the class name.
*/
public void setClassname(String s) {
@@ -218,7 +236,10 @@
private void run(CommandlineJava command) throws BuildException {
ExecuteJava exe = new ExecuteJava();
exe.setJavaCommand(command.getJavaCommand());
- exe.setClasspath(command.getClasspath());
+ Path p = new Path(project);
+ p.append(command.getClasspath());
+ addReferencesToPath(classpathReferences, p);
+ exe.setClasspath(p);
exe.execute(project);
}
@@ -252,10 +273,33 @@
for (int i=0; i<args.size(); i++) {
cmdj.createArgument().setValue((String) args.elementAt(i));
}
- if (cmdl.getClasspath() != null) {
- cmdj.createClasspath(project).append(cmdl.getClasspath());
+ if (cmdl.getClasspath() != null || classpathReferences.size() > 0) {
+ Path p = cmdj.createClasspath(project);
+ if (cmdl.getClasspath() != null) {
+ p.append(cmdl.getClasspath());
+ }
+ addReferencesToPath(classpathReferences, p);
}
run(cmdj);
}
+ /**
+ * Appends the referenced Path instances to the other path.
+ *
+ * @param v Vector of Reference objects referring to Path objects.
+ * @param p Path to append to.
+ */
+ private void addReferencesToPath(Vector v, Path p) {
+ for (int i=0; i<v.size(); i++) {
+ Reference r = (Reference) v.elementAt(i);
+ Object o = r.getReferencedObject(project);
+ if (o instanceof Path) {
+ p.append((Path) o);
+ } else {
+ String msg = r.getRefId()+" doesn\'t denote a classpath";
+ throw new BuildException(msg, location);
+ }
+ }
+ }
+
}
1.32 +60 -3
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java
Index: Javac.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Javac.java 2000/08/07 11:13:25 1.31
+++ Javac.java 2000/08/07 13:58:35 1.32
@@ -100,11 +100,13 @@
private Path src;
private File destDir;
private Path compileClasspath;
+ private Vector classpathReferences = new Vector();
private boolean debug = false;
private boolean optimize = false;
private boolean deprecation = false;
private String target;
private Path bootclasspath;
+ private Vector bootClasspathReferences = new Vector();
private Path extdirs;
private static String lSep = System.getProperty("line.separator");
@@ -164,6 +166,22 @@
}
/**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void addClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void setClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
* Sets the bootclasspath that will be used to compile the classes
* against.
*/
@@ -186,6 +204,22 @@
}
/**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void addBootClasspathRef(Reference r) {
+ bootClasspathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void setBootClasspathRef(Reference r) {
+ bootClasspathReferences.addElement(r);
+ }
+
+ /**
* Sets the extension directories that will be used during the
* compilation.
*/
@@ -355,6 +389,7 @@
if (compileClasspath != null) {
addExistingToClasspath(classpath,compileClasspath);
}
+ addReferencesToPath(classpathReferences, classpath);
// add the system classpath
@@ -505,7 +540,8 @@
if (optimize) {
cmd.createArgument().setValue("-O");
}
- if (bootclasspath != null) {
+ if (bootclasspath != null || bootClasspathReferences.size() > 0) {
+ addReferencesToPath(bootClasspathReferences,
createBootclasspath());
cmd.createArgument().setValue("-bootclasspath");
cmd.createArgument().setPath(bootclasspath);
}
@@ -559,7 +595,8 @@
// Jikes doesn't support bootclasspath dir (-bootclasspath)
// so we'll emulate it for compatibility and convenience.
- if (bootclasspath != null) {
+ if (bootclasspath != null || bootClasspathReferences.size() > 0) {
+ addReferencesToPath(bootClasspathReferences,
createBootclasspath());
classpath.append(bootclasspath);
}
@@ -713,7 +750,7 @@
/**
* Emulation of extdirs feature in java >= 1.2.
- * This method adds all file in the given
+ * This method adds all files in the given
* directories (but not in sub-directories!) to the classpath,
* so that you don't have to specify them all one by one.
* @param classpath - Path to append files to
@@ -740,5 +777,25 @@
classpath.addFileset(fs);
}
}
+
+ /**
+ * Appends the referenced Path instances to the other path.
+ *
+ * @param v Vector of Reference objects referring to Path objects.
+ * @param p Path to append to.
+ */
+ private void addReferencesToPath(Vector v, Path p) {
+ for (int i=0; i<v.size(); i++) {
+ Reference r = (Reference) v.elementAt(i);
+ Object o = r.getReferencedObject(project);
+ if (o instanceof Path) {
+ p.append((Path) o);
+ } else {
+ String msg = r.getRefId()+" doesn\'t denote a classpath";
+ throw new BuildException(msg, location);
+ }
+ }
+ }
+
}
1.25 +105 -8
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
Index: Javadoc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- Javadoc.java 2000/08/04 10:23:25 1.24
+++ Javadoc.java 2000/08/07 13:58:35 1.25
@@ -60,6 +60,7 @@
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
import java.io.*;
import java.util.*;
@@ -119,7 +120,8 @@
private Path path;
private Vector params = new Vector();
-
+ private Vector pathRefs = new Vector();
+
public void setName(String name) {
this.name = name;
}
@@ -137,6 +139,7 @@
}
public Path getPath() {
+ addReferencesToPath(pathRefs, path);
return path;
}
@@ -147,6 +150,22 @@
return path;
}
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <pathref> element.
+ */
+ public void addPathRef(Reference r) {
+ pathRefs.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <pathref> element.
+ */
+ public void setPathRef(Reference r) {
+ pathRefs.addElement(r);
+ }
+
public DocletParam createParam() {
DocletParam param = new DocletParam();
params.addElement(param);
@@ -196,8 +215,10 @@
private String packageList = null;
private Vector links = new Vector(2);
private Vector groups = new Vector(2);
+ private Vector classpathReferences = new Vector();
+ private Vector bootClasspathReferences = new Vector();
+ private Vector sourcepathReferences = new Vector();
-
public void setMaxmemory(String max){
if(javadoc1){
cmd.createArgument().setValue("-J-mx" + max);
@@ -223,6 +244,22 @@
}
return sourcePath;
}
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <sourcepathref> element.
+ */
+ public void addSourcepathRef(Reference r) {
+ sourcepathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <sourcepathref> element.
+ */
+ public void setSourcepathRef(Reference r) {
+ sourcepathReferences.addElement(r);
+ }
+
public void setDestdir(File dir) {
cmd.createArgument().setValue("-d");
cmd.createArgument().setFile(dir);
@@ -266,6 +303,13 @@
doclet.setPath(src);
}
+ public void setDocletPathRef(Reference r) {
+ if (doclet == null) {
+ doclet = new DocletInfo();
+ }
+ doclet.setPathRef(r);
+ }
+
public DocletInfo createDoclet() {
doclet = new DocletInfo();
return doclet;
@@ -287,6 +331,22 @@
}
return classpath;
}
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void addClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void setClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
public void setBootclasspath(Path src) {
if (bootclasspath == null) {
bootclasspath = src;
@@ -300,6 +360,22 @@
}
return bootclasspath;
}
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <bootclasspathref> element.
+ */
+ public void addBootClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <bootclasspathref> element.
+ */
+ public void setBootClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
public void setExtdirs(String src) {
if (!javadoc1) {
cmd.createArgument().setValue("-extdirs");
@@ -522,14 +598,14 @@
if (classpath == null)
classpath = Path.systemClasspath;
+ addReferencesToPath(classpathReferences, classpath);
+ addReferencesToPath(sourcepathReferences, sourcePath);
- if ( (!javadoc1) || (sourcePath == null) ) {
+ if (!javadoc1) {
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(classpath);
- if (sourcePath != null) {
- cmd.createArgument().setValue("-sourcepath");
- cmd.createArgument().setPath(sourcePath);
- }
+ cmd.createArgument().setValue("-sourcepath");
+ cmd.createArgument().setPath(sourcePath);
} else {
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setValue(sourcePath.toString() +
@@ -570,7 +646,9 @@
}
}
}
- if (bootclasspath != null) {
+ if (bootclasspath != null || bootClasspathReferences.size() > 0)
{
+ addReferencesToPath(bootClasspathReferences,
+ createBootclasspath());
cmd.createArgument().setValue("-bootclasspath");
cmd.createArgument().setPath(bootclasspath);
}
@@ -694,6 +772,25 @@
}
}
+ /**
+ * Appends the referenced Path instances to the other path.
+ *
+ * @param v Vector of Reference objects referring to Path objects.
+ * @param p Path to append to.
+ */
+ private void addReferencesToPath(Vector v, Path p) {
+ for (int i=0; i<v.size(); i++) {
+ Reference r = (Reference) v.elementAt(i);
+ Object o = r.getReferencedObject(project);
+ if (o instanceof Path) {
+ p.append((Path) o);
+ } else {
+ String msg = r.getRefId()+" doesn\'t denote a classpath";
+ throw new BuildException(msg, location);
+ }
+ }
+ }
+
/**
* Given a source path, a list of package patterns, fill the given list
* with the packages found in that path subdirs matching one of the given
1.12 +36 -7
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java
Index: Rmic.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Rmic.java 2000/08/02 09:24:22 1.11
+++ Rmic.java 2000/08/07 13:58:35 1.12
@@ -58,6 +58,7 @@
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
import java.io.*;
import java.util.StringTokenizer;
@@ -96,6 +97,7 @@
private boolean filtering = false;
private Vector compileList = new Vector();
+ private Vector classpathReferences = new Vector();
public void setBase(String base) {
this.base = base;
@@ -136,7 +138,7 @@
}
/**
- * Maybe creates a nesetd classpath element.
+ * Maybe creates a nested classpath element.
*/
public Path createClasspath() {
if (compileClasspath == null) {
@@ -146,10 +148,25 @@
}
/**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void addClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void setClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
+ /**
* Indicates that the classes found by the directory match should be
* checked to see if they implement java.rmi.Remote.
- * This defaults to false if not set.
- */
+ * This defaults to false if not set. */
public void setVerify(String verify) {
this.verify = Project.toBoolean(verify);
}
@@ -170,7 +187,19 @@
if (null != sourceBase) {
sourceBaseFile = project.resolveFile(sourceBase);
}
- String classpath = getCompileClasspath(baseDir);
+ Path classpath = getCompileClasspath(baseDir);
+
+ for (int i=0; i<classpathReferences.size(); i++) {
+ Reference r = (Reference) classpathReferences.elementAt(i);
+ Object o = r.getReferencedObject(project);
+ if (o instanceof Path) {
+ classpath.append((Path) o);
+ } else {
+ String msg = r.getRefId()+" doesn\'t denote a classpath";
+ throw new BuildException(msg, location);
+ }
+ }
+
// scan base dirs to build up compile lists only if a
// specific classname is not given
@@ -193,7 +222,7 @@
args[i++] = "-d";
args[i++] = baseDir.getAbsolutePath();
args[i++] = "-classpath";
- args[i++] = classpath;
+ args[i++] = classpath.toString();
if (null != stubVersion) {
if ("1.1".equals(stubVersion))
args[i++] = "-v1.1";
@@ -369,7 +398,7 @@
// XXX
// we need a way to not use the current classpath.
- private String getCompileClasspath(File baseFile) {
+ private Path getCompileClasspath(File baseFile) {
// add dest dir to classpath so that previously compiled and
// untouched classes are on classpath
Path classpath = new Path(project, baseFile.getAbsolutePath());
@@ -390,7 +419,7 @@
addExistingToClasspath(classpath, new Path(project, bootcp));
}
}
- return classpath.toString();
+ return classpath;
}
/**
1.6 +0 -1
jakarta-ant/src/main/org/apache/tools/ant/types/Commandline.java
Index: Commandline.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Commandline.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Commandline.java 2000/08/07 11:17:12 1.5
+++ Commandline.java 2000/08/07 13:58:35 1.6
@@ -108,7 +108,6 @@
public class Argument {
private String[] parts;
- private Reference pathRef;
/**
* Sets a single commandline argument.