From 2f3fc4ceb269ba3d0285afb816295ff76e503b10 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Fri, 5 Jan 2001 14:26:27 +0000 Subject: [PATCH] Address anomolies where classpath is now being interpreted differently by different tasks due to my change to javac and the introduction of ${build.sysclasspath} git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268407 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/AntClassLoader.java | 6 ++-- .../org/apache/tools/ant/taskdefs/Javac.java | 23 +------------ .../apache/tools/ant/taskdefs/Javadoc.java | 2 ++ .../tools/ant/types/CommandlineJava.java | 2 +- src/main/org/apache/tools/ant/types/Path.java | 34 +++++++++++++++++++ 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index 90e6c1c68..9b3b25a19 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -105,11 +105,13 @@ public class AntClassLoader extends ClassLoader { * Create a classloader for the given project using the classpath given. * * @param project the project to ehich this classloader is to belong. - * @param classpath the classpath to use to load the classes. + * @param classpath the classpath to use to load the classes. This + * is combined with the system classpath in a manner + * determined by the value of ${build.sysclasspath} */ public AntClassLoader(Project project, Path classpath) { this.project = project; - this.classpath = classpath; + this.classpath = classpath.concatSystemClasspath(); // JDK > 1.1 should add these by default, but some VMs don't addSystemPackageRoot("java"); diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 2f6ea4ae9..710d5ac1e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -420,28 +420,7 @@ public class Javac extends MatchingTask { if (compileClasspath == null) { classpath.addExisting(Path.systemClasspath); } else { - String order = project.getProperty("build.sysclasspath"); - if (order == null) order="first"; - - if (order.equals("only")) { - // only: the developer knows what (s)he is doing - classpath.addExisting(Path.systemClasspath); - - } else if (order.equals("last")) { - // last: don't trust the developer - classpath.addExisting(compileClasspath); - classpath.addExisting(Path.systemClasspath); - - } else if (order.equals("ignore")) { - // ignore: don't trust anyone - classpath.addExisting(compileClasspath); - addRuntime = true; - - } else { - // first: developer could use a little help - classpath.addExisting(Path.systemClasspath); - classpath.addExisting(compileClasspath); - } + classpath.addExisting(compileClasspath.concatSystemClasspath()); } // optionally add the runtime classes diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 8b16e56ac..91ffe990d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -571,6 +571,8 @@ public class Javadoc extends Task { // ------------------------------------------------ general javadoc arguments if (classpath == null) classpath = Path.systemClasspath; + else + classpath = classpath.concatSystemClasspath(); if (!javadoc1) { toExecute.createArgument().setValue("-classpath"); diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index ac8df3515..f870a1d32 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -190,7 +190,7 @@ public class CommandlineJava implements Cloneable { } if (classpath != null && classpath.size() > 0) { result[pos++] = "-classpath"; - result[pos++] = classpath.toString(); + result[pos++] = classpath.concatSystemClasspath().toString(); } System.arraycopy(javaCommand.getCommandline(), 0, result, pos, javaCommand.size()); diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index 050dfe44c..d435f76ed 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -466,4 +466,38 @@ public class Path extends DataType implements Cloneable { } } + /** + * Concatenates the system class path in the order specified + * by the ${build.sysclasspath} property. + */ + public Path concatSystemClasspath() { + + Path result = new Path(project); + + String order = project.getProperty("build.sysclasspath"); + if (order == null) order="first"; + + if (order.equals("only")) { + // only: the developer knows what (s)he is doing + result.addExisting(Path.systemClasspath); + + } else if (order.equals("last")) { + // last: don't trust the developer + result.addExisting(this); + result.addExisting(Path.systemClasspath); + + } else if (order.equals("ignore")) { + // ignore: don't trust anyone + result.addExisting(this); + + } else { + // first: developer could use a little help + result.addExisting(Path.systemClasspath); + result.addExisting(this); + } + + return result; + + } + }