bodewig 02/02/26 02:11:19
Modified: . WHATSNEW
src/main/org/apache/tools/ant/taskdefs/optional/junit
JUnitTask.java
docs/manual/OptionalTasks junit.html
Log:
Add an attribute to avoid <junit>'s classpath magic.
Revision Changes Path
1.215 +5 -0 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.214
retrieving revision 1.215
diff -u -r1.214 -r1.215
--- WHATSNEW 23 Feb 2002 20:42:39 -0000 1.214
+++ WHATSNEW 26 Feb 2002 10:11:19 -0000 1.215
@@ -183,6 +183,11 @@
* <property> now supports a 'prefix' attribute when loading from a file
or resource.
+* In Ant 1.4 a feature has been added to the <junit> task that would
+ add ant.jar, optional.jar and junit.jar implicitly to the classpath -
+ this feature can now be disabled by setting the new includeantruntime
+ attribute to false.
+
Changes from Ant 1.4 to Ant 1.4.1
===========================================
1.37 +32 -8
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Index: JUnitTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- JUnitTask.java 25 Feb 2002 20:01:15 -0000 1.36
+++ JUnitTask.java 26 Feb 2002 10:11:19 -0000 1.37
@@ -141,7 +141,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Gerrit Riessen</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Erik Hatcher</a>
*
- * @version $Revision: 1.36 $
+ * @version $Revision: 1.37 $
*
* @see JUnitTest
* @see BatchTest
@@ -162,6 +162,9 @@
private boolean newEnvironment = false;
private Environment env = new Environment();
+ private boolean includeAntRuntime = true;
+ private Path antRuntimeClasses = null;
+
/**
* Tells this task whether to smartly filter the stack frames of JUnit
testcase
* errors and failures before reporting them. This property is applied
on all
@@ -395,6 +398,15 @@
}
/**
+ * Whether to include ant.jar, optional.jar and junit.jar in the forked
VM.
+ *
+ * @since 1.37, Ant 1.5
+ */
+ public void setIncludeantruntime(boolean b) {
+ includeAntRuntime = b;
+ }
+
+ /**
* Creates a new JUnitRunner and enables fork of a new Java VM.
*/
public JUnitTask() throws Exception {
@@ -407,6 +419,7 @@
* without having to specify them directly.
*/
public void init() {
+ antRuntimeClasses = new Path(getProject());
addClasspathEntry("/junit/framework/TestCase.class");
addClasspathEntry("/org/apache/tools/ant/Task.class");
addClasspathEntry("/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.class");
@@ -493,6 +506,13 @@
cmd.createArgument().setValue("filtertrace=" +
test.getFiltertrace());
cmd.createArgument().setValue("haltOnError=" +
test.getHaltonerror());
cmd.createArgument().setValue("haltOnFailure=" +
test.getHaltonfailure());
+ if (includeAntRuntime) {
+ log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH",
+ Project.MSG_VERBOSE);
+ cmd.createClasspath(getProject()).createPath()
+ .append(antRuntimeClasses);
+ }
+
if (summary) {
log("Running " + test.getName(), Project.MSG_INFO);
cmd.createArgument().setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter");
@@ -606,7 +626,13 @@
AntClassLoader cl = null;
try {
log("Using System properties " + System.getProperties(),
Project.MSG_VERBOSE);
- Path classpath = commandline.getClasspath();
+ Path classpath = (Path) commandline.getClasspath().clone();
+ if (includeAntRuntime) {
+ log("Implicitly adding "+antRuntimeClasses+" to CLASSPATH",
+ Project.MSG_VERBOSE);
+ classpath.append(antRuntimeClasses);
+ }
+
if (classpath != null) {
cl = new AntClassLoader(null, project, classpath, false);
log("Using CLASSPATH " + cl.getClasspath(),
@@ -722,15 +748,13 @@
if (u.startsWith("jar:file:")) {
int pling = u.indexOf("!");
String jarName = u.substring(9, pling);
- log("Implicitly adding "+jarName+" to classpath",
- Project.MSG_DEBUG);
- createClasspath().setLocation(new File((new
File(jarName)).getAbsolutePath()));
+ log("Found "+jarName, Project.MSG_DEBUG);
+ antRuntimeClasses.createPath().setLocation(new File((new
File(jarName)).getAbsolutePath()));
} else if (u.startsWith("file:")) {
int tail = u.indexOf(resource);
String dirName = u.substring(5, tail);
- log("Implicitly adding "+dirName+" to classpath",
- Project.MSG_DEBUG);
- createClasspath().setLocation(new File((new
File(dirName)).getAbsolutePath()));
+ log("Found "+dirName, Project.MSG_DEBUG);
+ antRuntimeClasses.createPath().setLocation(new File((new
File(dirName)).getAbsolutePath()));
} else {
log("Don\'t know how to handle resource URL "+u,
Project.MSG_DEBUG);
1.14 +6 -0 jakarta-ant/docs/manual/OptionalTasks/junit.html
Index: junit.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/junit.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- junit.html 3 Feb 2002 22:09:09 -0000 1.13
+++ junit.html 26 Feb 2002 10:11:19 -0000 1.14
@@ -99,6 +99,12 @@
disabled.</td>
<td align="center" valign="top">No, default is "false".</td>
</tr>
+ <tr>
+ <td valign="top">includeantruntime</td>
+ <td valign="top">implicitly add the Ant classes required to run
+ the tests and JUnit to the classpath in forked mode.</td>
+ <td align="center" valign="top">No, default is "true".</td>
+ </tr>
</table>
<h3><a name="nested">Nested Elements</a></h3>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>