diff --git a/WHATSNEW b/WHATSNEW
index 5e663db23..5de68d80a 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -23,8 +23,8 @@ Changes that could break older environments:
* will no longer fail if the file to be loaded doesn't exist.
-* XML namespaces are now enabled in the XML parser, meaning XML namespace
- declarations no longer cause errors.
+* XML namespaces are now enabled in the XML parser, meaning XML namespace
+ declarations no longer cause errors.
* The and tasks now require Jakarta Commons Net instead
of the older ORO Netcomponents version. See
@@ -82,7 +82,7 @@ Fixed bugs:
* output and error streams can now be redirected independently
to either a property or a file (or both)
-* TarEntry's File-arg constructor would fail with a
+* TarEntry's File-arg constructor would fail with a
StringIndexOutOfBoundsException on all OSes where os.name is shorter
than seven characters. Bugzilla Report 18105.
@@ -112,7 +112,7 @@ Fixed bugs:
* Perforce tasks relying on output from the server such as and
were hanging. Bugzilla Reports 18129 and 18956.
-* build.sh install had a problem on cygwin (with REALANTHOME).
+* build.sh install had a problem on cygwin (with REALANTHOME).
Bugzilla Report 17257
* didn't work for multi-byte encodings if byline was false.
@@ -139,19 +139,19 @@ Fixed bugs:
* selector : make ignoreFileTimes effectively default to true
and fix a bug in the comparison of timestamps. Bugzilla Report 20205.
-* selector can now be nested directly under a fileset
+* selector can now be nested directly under a fileset
Bugzilla Report 20220.
Other changes:
--------------
* Six new Clearcase tasks added.
-* A new filter reader namely tokenfilter has been added. Bugzilla
+* A new filter reader namely tokenfilter has been added. Bugzilla
Report 18312.
* A new attribute named skip is added to the TailFilter and
HeadFilter filter readers.
-
+
* Shipped XML parser is now Xerces 2.4.0
* The filesetmanifest attribute of has been reenabled.
@@ -223,25 +223,25 @@ Other changes:
all compilers.
* a new attribute "globalopts" can be added to all Perforce tasks.
- You can put in it all the strings described by p4 help usage. Refer to
+ You can put in it all the strings described by p4 help usage. Refer to
the docs for more information.
* new Perforce tasks , , and
-* will change the property p4.change if the Perforce server
+* will change the property p4.change if the Perforce server
renumbers the change list.
- It will set the property p4.needsresolve if the submit fails,
+ It will set the property p4.needsresolve if the submit fails,
and the message says that file(s) need to be resolved.
* now has an optional encoding attribute to support
replacing in files that are in a different encoding than the
platform's default.
-
+
* The task may now have its input redirected from either a file
or a string from the build file. The error output can be separated
to a different file when outut is redirected. standard error may be
logged to the Ant log when redirecting output to a file
-
+
* The task also supports the input redirection and separate
error streams introduced to the task. In addition, it is now
possible to save the output into a property for use within the build
@@ -302,7 +302,7 @@ Other changes:
* has a new attribute encoding. Bugzilla Report 15434.
* has new attributes user and password for SMTP auth.
-maillogger can also use this.
+maillogger can also use this.
The implementation only with JavaMail (encoding="MIME").
Implementation with plain mail remains to do.
Bugzilla Report 5969.
@@ -384,6 +384,8 @@ Bugzilla Report 5969.
* and now support a nested element that
will be ignored if not forking a new VM.
+* 's nested elements now support if/unless clauses.
+
Changes from Ant 1.5.2 to Ant 1.5.3
===================================
@@ -426,7 +428,7 @@ Fixed bugs:
Other Changes:
--------------
-* Added ability to specify manifest encoding for the and
+* Added ability to specify manifest encoding for the and
tasks
Changes from Ant 1.5.1 to Ant 1.5.2
@@ -515,7 +517,7 @@ Fixed bugs:
* Corrected a problem in XMLLogger where it would not associated
messages with a taskdef'd task
-* now works when using attributes (i.e. not filesets) and pointing
+* now works when using attributes (i.e. not filesets) and pointing
to the same file
* Java task (and output system) now stores output which doos not end
diff --git a/docs/manual/OptionalTasks/junit.html b/docs/manual/OptionalTasks/junit.html
index 46961f33a..fcac6c1a8 100644
--- a/docs/manual/OptionalTasks/junit.html
+++ b/docs/manual/OptionalTasks/junit.html
@@ -285,6 +285,16 @@ documents and will be dropped.
sent to a file.
No; default is true . |
+
+ if |
+ Only use formatter if the named property is set. |
+ No; default is true . |
+
+
+ unless |
+ Only use formatter if the named property is not set. |
+ No; default is true . |
+
test
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
index 3c87031b0..99474b443 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
@@ -59,6 +59,7 @@ import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;
/**
@@ -76,6 +77,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute;
* must be set.
*
* @author Stefan Bodewig
+ * @author Eli Tucker
*
* @see JUnitTask
* @see XMLJUnitResultFormatter
@@ -90,6 +92,8 @@ public class FormatterElement {
private OutputStream out = System.out;
private File outFile;
private boolean useFile = true;
+ private String ifProperty;
+ private String unlessProperty;
/**
* Quick way to use a standard formatter.
@@ -173,6 +177,42 @@ public class FormatterElement {
return useFile;
}
+ /**
+ * Set whether this formatter should be used. It will be
+ * used if the property has been set, otherwise it won't.
+ * @param ifProperty name of property
+ */
+ public void setIf(String ifProperty)
+ {
+ this.ifProperty = ifProperty;
+ }
+
+ /**
+ * Set whether this formatter should NOT be used. It
+ * will not be used if the property has been set, orthwise it
+ * will be used.
+ * @param unlessProperty name of property
+ */
+ public void setUnless(String unlessProperty)
+ {
+ this.unlessProperty = unlessProperty;
+ }
+
+ /**
+ * Ensures that the selector passes the conditions placed
+ * on it with if
and unless
properties.
+ */
+ public boolean shouldUse(Task t) {
+ if (ifProperty != null && t.getProject().getProperty(ifProperty) == null) {
+ return false;
+ } else if (unlessProperty != null &&
+ t.getProject().getProperty(unlessProperty) != null) {
+ return false;
+ }
+
+ return true;
+ }
+
/**
* @since Ant 1.2
*/
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 d639c07fb..1ca481350 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
@@ -147,6 +147,7 @@ import junit.framework.TestResult;
* @author Gerrit Riessen
* @author Erik Hatcher
* @author Martijn Kruithof>
+ * @author Eli Tucker
*
* @version $Revision$
*
@@ -653,15 +654,17 @@ public class JUnitTask extends Task {
final FormatterElement[] feArray = mergeFormatters(test);
for (int i = 0; i < feArray.length; i++) {
FormatterElement fe = feArray[i];
- formatterArg.append("formatter=");
- formatterArg.append(fe.getClassname());
- File outFile = getOutput(fe, test);
- if (outFile != null) {
- formatterArg.append(",");
- formatterArg.append(outFile);
+ if(fe.shouldUse(this)) {
+ formatterArg.append("formatter=");
+ formatterArg.append(fe.getClassname());
+ File outFile = getOutput(fe, test);
+ if (outFile != null) {
+ formatterArg.append(",");
+ formatterArg.append(outFile);
+ }
+ cmd.createArgument().setValue(formatterArg.toString());
+ formatterArg = new StringBuffer();
}
- cmd.createArgument().setValue(formatterArg.toString());
- formatterArg = new StringBuffer();
}
// Create a temporary file to pass the Ant properties to the
@@ -868,13 +871,15 @@ public class JUnitTask extends Task {
final FormatterElement[] feArray = mergeFormatters(test);
for (int i = 0; i < feArray.length; i++) {
FormatterElement fe = feArray[i];
- File outFile = getOutput(fe, test);
- if (outFile != null) {
- fe.setOutfile(outFile);
- } else {
- fe.setOutput(getDefaultOutput());
+ if(fe.shouldUse(this)) {
+ File outFile = getOutput(fe, test);
+ if (outFile != null) {
+ fe.setOutfile(outFile);
+ } else {
+ fe.setOutput(getDefaultOutput());
+ }
+ runner.addFormatter(fe.createFormatter(cl));
}
- runner.addFormatter(fe.createFormatter(cl));
}
runner.run();