if there's no objection, i'd like to submit these patches to allow the "if" and "unless" attributes on the "Sequential" and "Parallel" tasks.
--
Matt Inger ([EMAIL PROTECTED])
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
as yet, is suspicious." -H.L. Mencken
--- jakarta-ant-1.4Beta2/src/main/org/apache/tools/ant/taskdefs/Sequential.java
Sun Aug 19 11:48:50 2001
+++ org/apache/tools/ant/taskdefs/Sequential.java Thu Aug 23 17:08:57 2001
@@ -66,6 +66,12 @@
*/
public class Sequential extends Task
implements TaskContainer {
+ /** To hold the "IF" attribute **/
+ private String ifProperty = null;
+
+ /** To hold the "UNLESS" attribute **/
+ private String unlessProperty = null;
+
/** Optional Vector holding the nested tasks */
private Vector nestedTasks = new Vector();
@@ -80,10 +86,35 @@
nestedTasks.addElement(nestedTask);
}
+ /***
+ * Add the if property
+ */
+ public void setIf(String prop)
+ {
+ ifProperty = prop;
+ }
+
+ /***
+ * Add the unless
+ */
+ public void setUnless(String prop)
+ {
+ unlessProperty = prop;
+ }
+
/**
* Execute all nestedTasks.
*/
public void execute() throws BuildException {
+ if (ifProperty != null && unlessProperty != null)
+ throw new BuildException("Both if and unless may not be specified
at the same time.");
+
+ if (ifProperty != null && project.getProperty(ifProperty) == null)
+ return;
+
+ if (unlessProperty != null && project.getProperty(unlessProperty) !=
null)
+ return;
+
for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();) {
Task nestedTask = (Task)e.nextElement();
nestedTask.perform();
--- jakarta-ant-1.4Beta2/src/main/org/apache/tools/ant/taskdefs/Parallel.java
Sun Aug 19 11:48:49 2001
+++ org/apache/tools/ant/taskdefs/Parallel.java Thu Aug 23 17:10:05 2001
@@ -67,6 +67,12 @@
*/
public class Parallel extends Task
implements TaskContainer {
+ /** To hold the "IF" attribute **/
+ private String ifProperty = null;
+
+ /** To hold the "UNLESS" attribute **/
+ private String unlessProperty = null;
+
/** Collection holding the nested tasks */
private Vector nestedTasks = new Vector();
@@ -81,12 +87,37 @@
nestedTasks.addElement(nestedTask);
}
+ /***
+ * Add the if property
+ */
+ public void setIf(String prop)
+ {
+ ifProperty = prop;
+ }
+
+ /***
+ * Add the unless
+ */
+ public void setUnless(String prop)
+ {
+ unlessProperty = prop;
+ }
+
/**
* Block execution until the specified time or for a
* specified amount of milliseconds and if defined,
* execute the wait status.
*/
public void execute() throws BuildException {
+ if (ifProperty != null && unlessProperty != null)
+ throw new BuildException("Both if and unless may not be specified
at the same time.");
+
+ if (ifProperty != null && project.getProperty(ifProperty) == null)
+ return;
+
+ if (unlessProperty != null && project.getProperty(unlessProperty) !=
null)
+ return;
+
TaskThread[] threads = new TaskThread[nestedTasks.size()];
int threadNumber = 0;
for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();
threadNumber++) {
