From 8162d141e44b778d135f9251277e85c922f0544c Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 14 Jul 2000 08:25:52 +0000 Subject: [PATCH] Make rmic, javac and javadoc use Path and add nested elements for various PATH like structures. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267782 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 5 +- src/main/org/apache/tools/ant/Path.java | 3 + .../org/apache/tools/ant/taskdefs/Javac.java | 139 +++++++++++------- .../apache/tools/ant/taskdefs/Javadoc.java | 95 ++++++++---- .../org/apache/tools/ant/taskdefs/Rmic.java | 48 +++--- 5 files changed, 190 insertions(+), 100 deletions(-) diff --git a/build.xml b/build.xml index 86b72b254..e1d0c1a0c 100644 --- a/build.xml +++ b/build.xml @@ -246,10 +246,13 @@ + + + + diff --git a/src/main/org/apache/tools/ant/Path.java b/src/main/org/apache/tools/ant/Path.java index 869d3484b..0f8a96e1c 100644 --- a/src/main/org/apache/tools/ant/Path.java +++ b/src/main/org/apache/tools/ant/Path.java @@ -91,6 +91,9 @@ public class Path { private Vector definition; + public static Path systemClasspath = + new Path(System.getProperty("java.class.path")); + public Path(String path) { this(); setPath(path); diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 5669b8a27..3eb957a38 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -109,14 +109,14 @@ public class Javac extends MatchingTask { 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,24 +187,66 @@ public class Javac extends MatchingTask { /** * 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(String bootclasspath) { - this.bootclasspath = project.translatePath(bootclasspath); + public void setBootclasspath(Path bootclasspath) { + if (this.bootclasspath == null) { + this.bootclasspath = bootclasspath; + } else { + this.bootclasspath.append(bootclasspath); + } + } + + /** + * Maybe creates a nested classpath element. + */ + 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; } /** @@ -387,14 +429,14 @@ public class Javac extends MatchingTask { * classes.zip 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 @@ public class Javac extends MatchingTask { // 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 @@ public class Javac extends MatchingTask { * @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