You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@locus.apache.org on 2000/08/11 14:55:13 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java
bodewig 00/08/11 05:55:13
Modified: docs junit.html
src/main/org/apache/tools/ant/taskdefs/optional/junit
JUnitTask.java
Log:
Added <classpathref> element to <junit>.
Revision Changes Path
1.4 +4 -2 jakarta-ant/docs/junit.html
Index: junit.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/junit.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- junit.html 2000/08/10 11:23:02 1.3
+++ junit.html 2000/08/11 12:55:12 1.4
@@ -70,8 +70,10 @@
<p><code>junit</code> supports a nested <code><classpath></code>
element, that represents a <a href="index.html#path">PATH like
-structure</a>. The value is ignore if <code>fork</code> is
-disabled.</p>
+structure</a>. PATHs defined elsewhere can be <a
+href="index.html#references">referred</a> to via nested
+<code><classpathref></code> elements. The value is ignored if
+<code>fork</code> is disabled.</p>
<h4>jvmarg</h4>
1.6 +23 -0 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JUnitTask.java 2000/08/09 13:12:12 1.5
+++ JUnitTask.java 2000/08/11 12:55:12 1.6
@@ -61,6 +61,7 @@
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
import java.io.File;
import java.io.IOException;
@@ -87,6 +88,7 @@
public class JUnitTask extends Task {
private CommandlineJava commandline = new CommandlineJava();
+ private Vector classpathReferences = new Vector();
private Vector tests = new Vector();
private Vector batchTests = new Vector();
private Vector formatters = new Vector();
@@ -132,6 +134,14 @@
return commandline.createVmArgument();
}
+ /**
+ * Adds a reference to a CLASSPATH defined elsewhere - nested
+ * <classpathref> element.
+ */
+ public void addClasspathRef(Reference r) {
+ classpathReferences.addElement(r);
+ }
+
public Path createClasspath() {
return commandline.createClasspath(project);
}
@@ -169,6 +179,19 @@
public void execute() throws BuildException {
boolean errorOccurred = false;
boolean failureOccurred = false;
+
+ Path classpath = commandline.createClasspath(project);
+ for (int i=0; i<classpathReferences.size(); i++) {
+ Reference r = (Reference) classpathReferences.elementAt(i);
+ Object o = r.getReferencedObject(project);
+ if (o instanceof Path) {
+ classpath.append((Path) o);
+ } else {
+ String msg = r.getRefId()+" doesn\'t denote a classpath";
+ throw new BuildException(msg, location);
+ }
+ }
+
Enumeration list = batchTests.elements();
while (list.hasMoreElements()) {