Browse Source

Add the runtime classes to the compile classpath if using jikes.

Submitted by:	Colin 't Hart <cthart@gbs.com.au>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267731 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
9541d91b85
1 changed files with 23 additions and 4 deletions
  1. +23
    -4
      src/main/org/apache/tools/ant/taskdefs/Javac.java

+ 23
- 4
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -302,7 +302,11 @@ public class Javac extends MatchingTask {
// XXX // XXX
// we need a way to not use the current classpath. // we need a way to not use the current classpath.


private String getCompileClasspath() {
/**
* @param addRuntime Shall <code>rt.jar</code> or
* <code>classes.zip</code> be added to the classpath.
*/
private String getCompileClasspath(boolean addRuntime) {
StringBuffer classpath = new StringBuffer(); StringBuffer classpath = new StringBuffer();


// add dest dir to classpath so that previously compiled and // add dest dir to classpath so that previously compiled and
@@ -321,6 +325,21 @@ public class Javac extends MatchingTask {
// add the system classpath // add the system classpath


addExistingToClasspath(classpath,System.getProperty("java.class.path")); addExistingToClasspath(classpath,System.getProperty("java.class.path"));
if (addRuntime) {
if (Project.getJavaVersion() == Project.JAVA_1_1) {
addExistingToClasspath(classpath,
System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + "classes.zip");
} else {
addExistingToClasspath(classpath,
System.getProperty("java.home")
+ File.separator +"jre"
+ File.separator + "lib"
+ File.separator + "rt.jar");
}
}
return classpath.toString(); return classpath.toString();
} }


@@ -360,7 +379,7 @@ public class Javac extends MatchingTask {


private void doClassicCompile() throws BuildException { private void doClassicCompile() throws BuildException {
project.log("Using classic compiler", project.MSG_VERBOSE); project.log("Using classic compiler", project.MSG_VERBOSE);
String classpath = getCompileClasspath();
String classpath = getCompileClasspath(false);
Vector argList = new Vector(); Vector argList = new Vector();


if (deprecation == true) if (deprecation == true)
@@ -441,7 +460,7 @@ public class Javac extends MatchingTask {


private void doModernCompile() throws BuildException { private void doModernCompile() throws BuildException {
project.log("Using modern compiler", project.MSG_VERBOSE); project.log("Using modern compiler", project.MSG_VERBOSE);
String classpath = getCompileClasspath();
String classpath = getCompileClasspath(false);
Vector argList = new Vector(); Vector argList = new Vector();


if (deprecation == true) if (deprecation == true)
@@ -538,7 +557,7 @@ public class Javac extends MatchingTask {
project.log("Using jikes compiler",project.MSG_VERBOSE); project.log("Using jikes compiler",project.MSG_VERBOSE);


StringBuffer classpath = new StringBuffer(); StringBuffer classpath = new StringBuffer();
classpath.append(getCompileClasspath());
classpath.append(getCompileClasspath(true));


// Jikes doesn't support an extension dir (-extdir) // Jikes doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience. // so we'll emulate it for compatibility and convenience.


Loading…
Cancel
Save