Browse Source

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
master
Sam Ruby 24 years ago
parent
commit
2f3fc4ceb2
5 changed files with 42 additions and 25 deletions
  1. +4
    -2
      src/main/org/apache/tools/ant/AntClassLoader.java
  2. +1
    -22
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  3. +2
    -0
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  4. +1
    -1
      src/main/org/apache/tools/ant/types/CommandlineJava.java
  5. +34
    -0
      src/main/org/apache/tools/ant/types/Path.java

+ 4
- 2
src/main/org/apache/tools/ant/AntClassLoader.java View File

@@ -105,11 +105,13 @@ public class AntClassLoader extends ClassLoader {
* Create a classloader for the given project using the classpath given. * Create a classloader for the given project using the classpath given.
* *
* @param project the project to ehich this classloader is to belong. * @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) { public AntClassLoader(Project project, Path classpath) {
this.project = project; this.project = project;
this.classpath = classpath;
this.classpath = classpath.concatSystemClasspath();


// JDK > 1.1 should add these by default, but some VMs don't // JDK > 1.1 should add these by default, but some VMs don't
addSystemPackageRoot("java"); addSystemPackageRoot("java");


+ 1
- 22
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -420,28 +420,7 @@ public class Javac extends MatchingTask {
if (compileClasspath == null) { if (compileClasspath == null) {
classpath.addExisting(Path.systemClasspath); classpath.addExisting(Path.systemClasspath);
} else { } 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 // optionally add the runtime classes


+ 2
- 0
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -571,6 +571,8 @@ public class Javadoc extends Task {
// ------------------------------------------------ general javadoc arguments // ------------------------------------------------ general javadoc arguments
if (classpath == null) if (classpath == null)
classpath = Path.systemClasspath; classpath = Path.systemClasspath;
else
classpath = classpath.concatSystemClasspath();


if (!javadoc1) { if (!javadoc1) {
toExecute.createArgument().setValue("-classpath"); toExecute.createArgument().setValue("-classpath");


+ 1
- 1
src/main/org/apache/tools/ant/types/CommandlineJava.java View File

@@ -190,7 +190,7 @@ public class CommandlineJava implements Cloneable {
} }
if (classpath != null && classpath.size() > 0) { if (classpath != null && classpath.size() > 0) {
result[pos++] = "-classpath"; result[pos++] = "-classpath";
result[pos++] = classpath.toString();
result[pos++] = classpath.concatSystemClasspath().toString();
} }
System.arraycopy(javaCommand.getCommandline(), 0, System.arraycopy(javaCommand.getCommandline(), 0,
result, pos, javaCommand.size()); result, pos, javaCommand.size());


+ 34
- 0
src/main/org/apache/tools/ant/types/Path.java View File

@@ -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;

}

} }

Loading…
Cancel
Save