conor 00/08/09 07:09:50
Modified: src/main/org/apache/tools/ant/types Path.java
src/main/org/apache/tools/ant/taskdefs Javac.java
Log:
Move addExisting functionality from javac to Path
Fix error in Path constructor
Revision Changes Path
1.6 +24 -1 jakarta-ant/src/main/org/apache/tools/ant/types/Path.java
Index: Path.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/Path.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Path.java 2000/08/09 06:20:30 1.5
+++ Path.java 2000/08/09 14:09:37 1.6
@@ -130,7 +130,7 @@
createPathElement().setPath(path);
}
- public Path(Project p) {
+ public Path(Project project) {
this.project = project;
elements = new Vector();
}
@@ -187,6 +187,29 @@
if (elements.indexOf(l[i]) == -1) {
elements.addElement(l[i]);
}
+ }
+ }
+
+ /**
+ * Adds the components on the given path which exist to this
+ * Path. Components that don't exist, aren't added.
+ *
+ * @param source - source path whose components are examined for
existence
+ */
+ public void addExisting(Path source) {
+ String[] list = source.list();
+ for (int i=0; i<list.length; i++) {
+ File f = null;
+ if (project != null) {
+ f = project.resolveFile(list[i]);
+ }
+ else {
+ f = new File(list[i]);
+ }
+
+ if (f.exists()) {
+ setLocation(f);
+ }
}
}
1.34 +5 -34
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.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Javac.java 2000/08/08 06:29:47 1.33
+++ Javac.java 2000/08/09 14:09:49 1.34
@@ -387,32 +387,29 @@
// add our classpath to the mix
if (compileClasspath != null) {
- addExistingToClasspath(classpath,compileClasspath);
+ classpath.addExisting(compileClasspath);
}
addReferencesToPath(classpathReferences, classpath);
// add the system classpath
- addExistingToClasspath(classpath, Path.systemClasspath);
+ classpath.addExisting(Path.systemClasspath);
if (addRuntime) {
if (Project.getJavaVersion() == Project.JAVA_1_1) {
- addExistingToClasspath(classpath,
- new Path(null,
+ classpath.addExisting(new Path(null,
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,
- new Path(null,
+ classpath.addExisting(new Path(null,
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,
- new Path(null,
+ classpath.addExisting(new Path(null,
System.getProperty("java.home")
+ File.separator +"jre"
+ File.separator + "lib"
@@ -421,32 +418,6 @@
}
return classpath;
- }
-
-
- /**
- * Takes a Path, and adds each element of
- * another Path to a new classpath, if the components exist.
- * Components that don't exist, aren't added.
- * We do this, because jikes issues warnings for non-existant
- * files/dirs in his classpath, and these warnings are pretty
- * annoying.
- * @param target - target classpath
- * @param source - source classpath
- * to get file objects.
- */
- 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);
- } else {
- log("Dropping from classpath: "+
- f.getAbsolutePath(), Project.MSG_VERBOSE);
- }
- }
}
/**