From b5bd5af0590db16a907d2c845821623934a8ff0f Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Java
's classpath attribute is a PATH like structure and can also be set via a nested
classpath element.
The location of bootstrap class files can be specified using this
+PATH like structure - will be ignored
+if fork is not true
or the target VM doesn't
+support it (i.e. Java 1.1).
since Ant 1.6.
+It is possible to specify environment variables to pass to the forked VM via nested env elements. See the description in the diff --git a/docs/manual/OptionalTasks/junit.html b/docs/manual/OptionalTasks/junit.html index 9414b3b3d..46961f33a 100644 --- a/docs/manual/OptionalTasks/junit.html +++ b/docs/manual/OptionalTasks/junit.html @@ -228,6 +228,15 @@ description in the exec task.
Settings will be ignored if fork
is disabled.
The location of bootstrap class files can be specified using this
+PATH like structure - will be ignored
+if fork is not true
or the target VM doesn't
+support it (i.e. Java 1.1).
since Ant 1.6.
+The results of the tests can be printed in different
diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java
index 8bb3fde07..9092f57df 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Java.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Java.java
@@ -149,6 +149,11 @@ public class Java extends Task {
+ "JVM is used.", Project.MSG_WARN);
}
+ if (cmdl.getBootclasspath() != null) {
+ log("bootclasspath ignored when same JVM is used.",
+ Project.MSG_WARN);
+ }
+
log("Running in same VM " + cmdl.describeJavaCommand(),
Project.MSG_VERBOSE);
}
@@ -197,6 +202,14 @@ public class Java extends Task {
return cmdl.createClasspath(getProject()).createPath();
}
+ /**
+ * Adds a path to the bootclasspath.
+ * @since Ant 1.6
+ */
+ public Path createBootclasspath() {
+ return cmdl.createBootclasspath(getProject()).createPath();
+ }
+
/**
* Classpath to use, by reference.
*/
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index 5e2939d75..d639c07fb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -425,6 +425,14 @@ public class JUnitTask extends Task {
return commandline.createClasspath(getProject()).createPath();
}
+ /**
+ * Adds a path to the bootclasspath.
+ * @since Ant 1.6
+ */
+ public Path createBootclasspath() {
+ return commandline.createBootclasspath(getProject()).createPath();
+ }
+
/**
* Adds an environment variable; used when forking.
*
@@ -825,6 +833,11 @@ public class JUnitTask extends Task {
+ "the same VM.", Project.MSG_WARN);
}
+ if (commandline.getBootclasspath() != null) {
+ log("bootclasspath is ignored if running in the same VM.",
+ Project.MSG_WARN);
+ }
+
CommandlineJava.SysProperties sysProperties =
commandline.getSystemProperties();
if (sysProperties != null) {
diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java
index a55b9c9f7..2b9569326 100644
--- a/src/main/org/apache/tools/ant/types/CommandlineJava.java
+++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java
@@ -85,6 +85,7 @@ public class CommandlineJava implements Cloneable {
*/
private SysProperties sysProperties = new SysProperties();
private Path classpath = null;
+ private Path bootclasspath = null;
private String vmVersion;
private String maxMemory = null;
@@ -270,6 +271,16 @@ public class CommandlineJava implements Cloneable {
return classpath;
}
+ /**
+ * @since Ant 1.6
+ */
+ public Path createBootclasspath(Project p) {
+ if (bootclasspath == null) {
+ bootclasspath = new Path(p);
+ }
+ return bootclasspath;
+ }
+
public String getVmversion() {
return vmVersion;
}
@@ -294,11 +305,16 @@ public class CommandlineJava implements Cloneable {
result, pos, sysProperties.size());
pos += sysProperties.size();
}
- // classpath is a vm option too..
- Path fullClasspath = classpath != null ? classpath.concatSystemClasspath("ignore") : null;
- if (fullClasspath != null && fullClasspath.toString().trim().length() > 0) {
+
+ // classpath and bootclasspath are vm options too..
+ if (haveBootclasspath(false)) {
+ result[pos++] = "-Xbootclasspath:" + bootclasspath.toString();
+ }
+
+ if (haveClasspath()) {
result[pos++] = "-classpath";
- result[pos++] = fullClasspath.toString();
+ result[pos++] =
+ classpath.concatSystemClasspath("ignore").toString();
}
// JDK usage command line says that -jar must be the first option, as there is
@@ -377,10 +393,13 @@ public class CommandlineJava implements Cloneable {
public int size() {
int size = getActualVMCommand().size() + javaCommand.size() + sysProperties.size();
// classpath is "-classpath