bodewig 00/07/14 01:25:55
Modified: . build.xml
src/main/org/apache/tools/ant Path.java
src/main/org/apache/tools/ant/taskdefs Javac.java
Javadoc.java Rmic.java
Log:
Make rmic, javac and javadoc use Path and add nested elements for
various PATH like structures.
Revision Changes Path
1.38 +4 -1 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- build.xml 2000/07/13 16:35:02 1.37
+++ build.xml 2000/07/14 08:25:52 1.38
@@ -246,10 +246,13 @@
<javac srcdir="${src.tests.dir}"
destdir="${build.tests}"
- classpath="${lib.dir}/${name}.jar:${classpath}"
debug="on"
deprecation="off"
optimize="on" >
+ <classpath>
+ <pathelement location="${lib.dir}/${name}.jar" />
+ <pathelement path="${classpath}" />
+ </classpath>
<include name="**/*.java"/>
<exclude name="**/AllJUnitTests.java" unless="junit.present" />
<exclude name="**/EnumeratedAttributeTest.java" unless="junit.present"
/>
1.3 +3 -0 jakarta-ant/src/main/org/apache/tools/ant/Path.java
Index: Path.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Path.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Path.java 2000/07/14 07:14:42 1.2
+++ Path.java 2000/07/14 08:25:52 1.3
@@ -91,6 +91,9 @@
private Vector definition;
+ public static Path systemClasspath =
+ new Path(System.getProperty("java.class.path"));
+
public Path(String path) {
this();
setPath(path);
1.21 +87 -52
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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Javac.java 2000/07/12 09:55:44 1.20
+++ Javac.java 2000/07/14 08:25:52 1.21
@@ -109,14 +109,14 @@
private Vector srcPathElements = new Vector();
private Vector srcDirs= new Vector();
private File destDir;
- private String compileClasspath;
+ private Path compileClasspath;
private boolean debug = false;
private boolean optimize = false;
private boolean deprecation = false;
private boolean filtering = false;
private String target;
- private String bootclasspath;
- private String extdirs;
+ private Path bootclasspath;
+ private Path extdirs;
protected Vector compileList = new Vector();
protected Hashtable filecopyList = new Hashtable();
@@ -187,27 +187,69 @@
/**
* Set the classpath to be used for this compilation.
*/
- public void setClasspath(String classpath) {
- compileClasspath = project.translatePath(classpath);
+ public void setClasspath(Path classpath) {
+ if (compileClasspath == null) {
+ compileClasspath = classpath;
+ } else {
+ compileClasspath.append(classpath);
+ }
+ }
+
+ /**
+ * Maybe creates a nested classpath element.
+ */
+ public Path createClasspath() {
+ if (compileClasspath == null) {
+ compileClasspath = new Path();
+ }
+ return compileClasspath;
}
/**
* Sets the bootclasspath that will be used to compile the classes
* against.
+ */
+ public void setBootclasspath(Path bootclasspath) {
+ if (this.bootclasspath == null) {
+ this.bootclasspath = bootclasspath;
+ } else {
+ this.bootclasspath.append(bootclasspath);
+ }
+ }
+
+ /**
+ * Maybe creates a nested classpath element.
*/
- public void setBootclasspath(String bootclasspath) {
- this.bootclasspath = project.translatePath(bootclasspath);
+ public Path createBootclasspath() {
+ if (bootclasspath == null) {
+ bootclasspath = new Path();
+ }
+ return bootclasspath;
}
/**
* Sets the extension directories that will be used during the
* compilation.
*/
- public void setExtdirs(String extdirs) {
- this.extdirs = project.translatePath(extdirs);
+ public void setExtdirs(Path extdirs) {
+ if (this.extdirs == null) {
+ this.extdirs = extdirs;
+ } else {
+ this.extdirs.append(extdirs);
+ }
}
/**
+ * Maybe creates a nested classpath element.
+ */
+ public Path createExtdirs() {
+ if (extdirs == null) {
+ extdirs = new Path();
+ }
+ return extdirs;
+ }
+
+ /**
* Set the deprecation flag.
*/
public void setDeprecation(boolean deprecation) {
@@ -387,14 +429,14 @@
* <code>classes.zip</code> be added to the classpath.
*/
private String getCompileClasspath(boolean addRuntime) {
- StringBuffer classpath = new StringBuffer();
+ Path classpath = new Path();
// add dest dir to classpath so that previously compiled and
// untouched classes are on classpath
//classpath.append(sourceDir.getAbsolutePath());
//classpath.append(File.pathSeparator);
- classpath.append(destDir.getAbsolutePath());
+ classpath.setLocation(destDir.getAbsolutePath());
// add our classpath to the mix
@@ -404,26 +446,27 @@
// add the system classpath
-
addExistingToClasspath(classpath,System.getProperty("java.class.path"));
+ addExistingToClasspath(classpath, Path.systemClasspath);
if (addRuntime) {
if (Project.getJavaVersion() == Project.JAVA_1_1) {
addExistingToClasspath(classpath,
- System.getProperty("java.home")
- + File.separator + "lib"
- + File.separator + "classes.zip");
+ new
Path(System.getProperty("java.home")
+ + File.separator + "lib"
+ + File.separator
+ + "classes.zip"));
} else {
// JDK > 1.1 seems to set java.home to the JRE directory.
addExistingToClasspath(classpath,
- System.getProperty("java.home")
- + File.separator + "lib"
- + File.separator + "rt.jar");
+ new
Path(System.getProperty("java.home")
+ + File.separator + "lib"
+ + File.separator +
"rt.jar"));
// Just keep the old version as well and let
addExistingToPath
// sort it out.
addExistingToClasspath(classpath,
- System.getProperty("java.home")
- + File.separator +"jre"
- + File.separator + "lib"
- + File.separator + "rt.jar");
+ new
Path(System.getProperty("java.home")
+ + File.separator +"jre"
+ + File.separator + "lib"
+ + File.separator +
"rt.jar"));
}
}
@@ -442,21 +485,18 @@
* @param source - source classpath
* to get file objects.
*/
- private void addExistingToClasspath(StringBuffer target,String source) {
- StringTokenizer tok = new StringTokenizer(source,
- System.getProperty("path.separator"), false);
- while (tok.hasMoreTokens()) {
- File f = project.resolveFile(tok.nextToken());
-
- if (f.exists()) {
- target.append(File.pathSeparator);
- target.append(f.getAbsolutePath());
+ private void addExistingToClasspath(Path target, Path source) {
+ String[] list = source.list();
+ for (int i=0; i<list.length; i++) {
+ File f = project.resolveFile(list[i]);
+
+ if (f.exists()) {
+ target.setLocation(f.getAbsolutePath());
} else {
log("Dropping from classpath: "+
f.getAbsolutePath(), Project.MSG_VERBOSE);
}
- }
-
+ }
}
/**
@@ -496,10 +536,10 @@
argList.addElement("-classpath");
// Just add "sourcepath" to classpath ( for JDK1.1 )
if (Project.getJavaVersion().startsWith("1.1")) {
- argList.addElement(classpath + File.pathSeparator +
+ argList.addElement(classpath.toString() + File.pathSeparator +
getSourcePath());
} else {
- argList.addElement(classpath);
+ argList.addElement(classpath.toString());
argList.addElement("-sourcepath");
argList.addElement(getSourcePath());
if (target != null) {
@@ -515,11 +555,11 @@
}
if (bootclasspath != null) {
argList.addElement("-bootclasspath");
- argList.addElement(bootclasspath);
+ argList.addElement(bootclasspath.toString());
}
if (extdirs != null) {
argList.addElement("-extdirs");
- argList.addElement(extdirs);
+ argList.addElement(extdirs.toString());
}
log("Compilation args: " + argList.toString(),
@@ -582,7 +622,7 @@
argList.addElement("-d");
argList.addElement(destDir.getAbsolutePath());
argList.addElement("-classpath");
- argList.addElement(classpath);
+ argList.addElement(classpath.toString());
argList.addElement("-sourcepath");
argList.addElement(getSourcePath());
if (target != null) {
@@ -597,11 +637,11 @@
}
if (bootclasspath != null) {
argList.addElement("-bootclasspath");
- argList.addElement(bootclasspath);
+ argList.addElement(bootclasspath.toString());
}
if (extdirs != null) {
argList.addElement("-extdirs");
- argList.addElement(extdirs);
+ argList.addElement(extdirs.toString());
}
log("Compilation args: " + argList.toString(),
@@ -669,8 +709,7 @@
private void doJikesCompile() throws BuildException {
log("Using jikes compiler", Project.MSG_VERBOSE);
- StringBuffer classpath = new StringBuffer();
- classpath.append(getCompileClasspath(true));
+ Path classpath = new Path(getCompileClasspath(true));
// Jikes doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience.
@@ -678,8 +717,7 @@
// Jikes has no option for source-path so we
// will add it to classpath.
- classpath.append(File.pathSeparator);
- classpath.append(getSourcePath());
+ classpath.setPath(getSourcePath());
Vector argList = new Vector();
@@ -797,23 +835,20 @@
* so that you don't have to specify them all one by one.
* @param classpath - stringbuffer to append jar files to
*/
- private void addExtdirsToClasspath(StringBuffer classpath) {
+ private void addExtdirsToClasspath(Path classpath) {
// FIXME
// Should we scan files recursively? How does
// javac handle this?
if (extdirs != null) {
- StringTokenizer tok = new StringTokenizer(extdirs,
- File.pathSeparator,
- false);
- while (tok.hasMoreTokens()) {
- File dir = project.resolveFile(tok.nextToken());
+ String[] list = extdirs.list();
+ for (int j=0; j<list.length; j++) {
+ File dir = project.resolveFile(list[j]);
String[] files = dir.list(new JarFilenameFilter());
for (int i=0 ; i < files.length ; i++) {
File f = new File(dir,files[i]);
if (f.exists() && f.isFile()) {
- classpath.append(File.pathSeparator);
- classpath.append(f.getAbsolutePath());
+ classpath.setLocation(f.getAbsolutePath());
}
}
}
1.16 +68 -27
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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Javadoc.java 2000/07/08 17:35:51 1.15
+++ Javadoc.java 2000/07/14 08:25:52 1.16
@@ -111,7 +111,7 @@
public class DocletInfo {
private String name;
- private String path;
+ private Path path;
private Vector params = new Vector();
@@ -123,15 +123,26 @@
return name;
}
- public void setPath(String path) {
- this.path = Project.translatePath(path);
+ public void setPath(Path path) {
+ if (this.path == null) {
+ this.path = path;
+ } else {
+ this.path.append(path);
+ }
}
- public String getPath() {
+ public Path getPath() {
return path;
}
- public Object createParam() {
+ public Path createPath() {
+ if (path == null) {
+ path = new Path();
+ }
+ return path;
+ }
+
+ public DocletParam createParam() {
DocletParam param = new DocletParam();
params.addElement(param);
@@ -144,7 +155,7 @@
}
private String maxmemory = null;
- private String sourcePath = null;
+ private Path sourcePath = null;
private String additionalParam = null;
private File destDir = null;
private File overviewFile = null;
@@ -158,8 +169,8 @@
private boolean version = true;
private DocletInfo doclet = null;
private boolean old = false;
- private String classpath = null;
- private String bootclasspath = null;
+ private Path classpath = null;
+ private Path bootclasspath = null;
private String extdirs = null;
private boolean verbose = false;
private String locale = null;
@@ -199,8 +210,18 @@
additionalParam = src;
}
- public void setSourcepath(String src) {
- sourcePath = project.translatePath(src);
+ public void setSourcepath(Path src) {
+ if (sourcePath == null) {
+ sourcePath = src;
+ } else {
+ sourcePath.append(src);
+ }
+ }
+ public Path createSourcepath() {
+ if (sourcePath == null) {
+ sourcePath = new Path();
+ }
+ return sourcePath;
}
public void setDestdir(String src) {
destDir = project.resolveFile(src);
@@ -233,7 +254,7 @@
doclet.setName(src);
}
- public void setDocletPath(String src) {
+ public void setDocletPath(Path src) {
if (doclet == null) {
doclet = new DocletInfo();
}
@@ -248,11 +269,31 @@
public void setOld(String src) {
old = Project.toBoolean(src);
}
- public void setClasspath(String src) {
- classpath = project.translatePath(src);
+ public void setClasspath(Path src) {
+ if (classpath == null) {
+ classpath = src;
+ } else {
+ classpath.append(src);
+ }
+ }
+ public Path createClasspath() {
+ if (classpath == null) {
+ classpath = new Path();
+ }
+ return classpath;
}
- public void setBootclasspath(String src) {
- bootclasspath = project.translatePath(src);
+ public void setBootclasspath(Path src) {
+ if (bootclasspath == null) {
+ bootclasspath = src;
+ } else {
+ bootclasspath.append(src);
+ }
+ }
+ public Path createBootclasspath() {
+ if (bootclasspath == null) {
+ bootclasspath = new Path();
+ }
+ return bootclasspath;
}
public void setExtdirs(String src) {
extdirs = src;
@@ -420,7 +461,7 @@
// ------------------------------------------------ general javadoc arguments
if (classpath == null)
- classpath = System.getProperty("java.class.path");
+ classpath = Path.systemClasspath;
if(maxmemory != null){
@@ -434,15 +475,15 @@
if ( (!javadoc1) || (sourcePath == null) ) {
argList.addElement("-classpath");
- argList.addElement(classpath);
+ argList.addElement(classpath.toString());
if (sourcePath != null) {
argList.addElement("-sourcepath");
- argList.addElement(sourcePath);
+ argList.addElement(sourcePath.toString());
}
} else {
argList.addElement("-classpath");
- argList.addElement(sourcePath +
- System.getProperty("path.separator") + classpath);
+ argList.addElement(sourcePath.toString() +
+ System.getProperty("path.separator") + classpath.toString());
}
if (destDir != null) {
@@ -510,7 +551,7 @@
argList.addElement(doclet.getName());
if (doclet.getPath() != null) {
argList.addElement("-docletpath");
- argList.addElement(doclet.getPath());
+ argList.addElement(doclet.getPath().toString());
}
for (Enumeration e = doclet.getParams();
e.hasMoreElements();) {
DocletParam param = (DocletParam)e.nextElement();
@@ -527,7 +568,7 @@
}
if (bootclasspath != null) {
argList.addElement("-bootclasspath");
- argList.addElement(bootclasspath);
+ argList.addElement(bootclasspath.toString());
}
if (extdirs != null) {
argList.addElement("-extdirs");
@@ -712,15 +753,15 @@
* with the packages found in that path subdirs matching one of the given
* patterns.
*/
- private void evaluatePackages(String sourcePath, Vector packages, Vector
argList) {
+ private void evaluatePackages(Path sourcePath, Vector packages, Vector
argList) {
log("Parsing source files for packages", Project.MSG_INFO);
- log("Source path = " + sourcePath, Project.MSG_VERBOSE);
+ log("Source path = " + sourcePath.toString(), Project.MSG_VERBOSE);
log("Packages = " + packages, Project.MSG_VERBOSE);
Vector addedPackages = new Vector();
- PathTokenizer tokenizer = new PathTokenizer(sourcePath);
- while (tokenizer.hasMoreTokens()) {
- File source = new
File(project.translatePath(tokenizer.nextToken()));
+ String[] list = sourcePath.list();
+ for (int j=0; j<list.length; j++) {
+ File source = project.resolveFile(list[j]);
Hashtable map = mapClasses(source);
1.9 +28 -20
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Rmic.java 2000/07/13 08:11:33 1.8
+++ Rmic.java 2000/07/14 08:25:52 1.9
@@ -87,7 +87,7 @@
private String classname;
private String sourceBase;
private String stubVersion;
- private String compileClasspath;
+ private Path compileClasspath;
private boolean verify = false;
private boolean filtering = false;
@@ -123,8 +123,22 @@
/**
* Set the classpath to be used for this compilation.
*/
- public void setClasspath(String classpath) {
- compileClasspath = project.translatePath(classpath);
+ public void setClasspath(Path classpath) {
+ if (compileClasspath == null) {
+ compileClasspath = classpath;
+ } else {
+ compileClasspath.append(classpath);
+ }
+ }
+
+ /**
+ * Maybe creates a nesetd classpath element.
+ */
+ public Path createClasspath() {
+ if (compileClasspath == null) {
+ compileClasspath = new Path();
+ }
+ return compileClasspath;
}
/**
@@ -352,11 +366,9 @@
// we need a way to not use the current classpath.
private String getCompileClasspath(File baseFile) {
- StringBuffer classpath = new StringBuffer();
-
// add dest dir to classpath so that previously compiled and
// untouched classes are on classpath
- classpath.append(baseFile.getAbsolutePath());
+ Path classpath = new Path(baseFile.getAbsolutePath());
// add our classpath to the mix
@@ -365,14 +377,13 @@
}
// add the system classpath
+ addExistingToClasspath(classpath, Path.systemClasspath);
-
addExistingToClasspath(classpath,System.getProperty("java.class.path"));
// in jdk 1.2, the system classes are not on the visible classpath.
-
if (Project.getJavaVersion().startsWith("1.2")) {
String bootcp = System.getProperty("sun.boot.class.path");
if (bootcp != null) {
- addExistingToClasspath(classpath, bootcp);
+ addExistingToClasspath(classpath, new Path(bootcp));
}
}
return classpath.toString();
@@ -389,21 +400,18 @@
* @param source - source classpath
* to get file objects.
*/
- private void addExistingToClasspath(StringBuffer target,String source) {
- StringTokenizer tok = new StringTokenizer(source,
- System.getProperty("path.separator"), false);
- while (tok.hasMoreTokens()) {
- File f = project.resolveFile(tok.nextToken());
-
- if (f.exists()) {
- target.append(File.pathSeparator);
- target.append(f.getAbsolutePath());
+ private void addExistingToClasspath(Path target, Path source) {
+ String[] list = source.list();
+ for (int i=0; i<list.length; i++) {
+ File f = project.resolveFile(list[i]);
+
+ if (f.exists()) {
+ target.setLocation(f.getAbsolutePath());
} else {
log("Dropping from classpath: "+
f.getAbsolutePath(), Project.MSG_VERBOSE);
}
- }
-
+ }
}
}