conor 02/02/26 05:43:54
Modified: proposal/mutant/build ant1compat.xml
proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution
ComponentManager.java Frame.java
proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant
Task.java TaskContainer.java
proposal/mutant/src/java/antlibs/system antlib.xml
proposal/mutant/src/java/common/org/apache/ant/common/antlib
TaskContainer.java
Added:
proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system
Parallel.java Sequential.java
Log:
Make Ant1 containers work in mutant. Provide mutant versions of parallel and
sequential
Revision Changes Path
1.3 +2 -2 jakarta-ant/proposal/mutant/build/ant1compat.xml
Index: ant1compat.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/mutant/build/ant1compat.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -u -r1.2 -r1.3
--- ant1compat.xml 20 Feb 2002 13:43:14 -0000 1.2
+++ ant1compat.xml 26 Feb 2002 13:43:53 -0000 1.3
@@ -28,14 +28,14 @@
<exclude name="org/apache/tools/ant/taskdefs/RecorderEntry.java"/>
<exclude
name="org/apache/tools/ant/taskdefs/optional/Native2Ascii.java"/>
<exclude name="org/apache/tools/ant/taskdefs/optional/Javah.java"/>
- <!-- <exclude name="org/apache/tools/ant/taskdefs/Parallel.java"/> -->
- <!-- <exclude name="org/apache/tools/ant/taskdefs/Sequential.java"/> -->
<exclude name="org/apache/tools/ant/taskdefs/optional/jdepend/*.java"/>
</patternset>
<patternset id="converted">
<exclude name="org/apache/tools/ant/taskdefs/Ant.java"/>
<exclude name="org/apache/tools/ant/taskdefs/CallTarget.java"/>
+<!-- <exclude name="org/apache/tools/ant/taskdefs/Parallel.java"/>
+ <exclude name="org/apache/tools/ant/taskdefs/Sequential.java"/> -->
</patternset>
<fileset id="ant1src" dir="../../src/main">
1.8 +1 -1
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java
Index: ComponentManager.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/ComponentManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -u -r1.7 -r1.8
--- ComponentManager.java 25 Feb 2002 13:28:57 -0000 1.7
+++ ComponentManager.java 26 Feb 2002 13:43:53 -0000 1.8
@@ -766,7 +766,7 @@
Task nestedTask
= (Task)createComponent(nestedElementModel);
TaskContainer container = (TaskContainer)element;
- container.addTask(nestedTask);
+ container.addNestedTask(nestedTask);
} else {
if (setter.supportsNestedAdder(nestedElementName)) {
addNestedElement(factory, setter, element,
1.8 +9 -3
jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
Index: Frame.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -u -r1.7 -r1.8
--- Frame.java 25 Feb 2002 13:28:57 -0000 1.7
+++ Frame.java 26 Feb 2002 13:43:53 -0000 1.8
@@ -250,9 +250,15 @@
* @exception ExecutionException if the properties cannot be set
*/
protected void setMagicProperties() throws ExecutionException {
- // set up various magic properties
- setDataValue(MagicProperties.ANT_HOME,
- initConfig.getAntHome().toString(), true);
+ URL antHomeURL = initConfig.getAntHome();
+ String antHomeString = null;
+ if (antHomeURL.getProtocol().equals("file")) {
+ File antHome = new File(antHomeURL.getFile());
+ antHomeString = antHome.getAbsolutePath();
+ } else {
+ antHomeString = antHomeURL.toString();
+ }
+ setDataValue(MagicProperties.ANT_HOME, antHomeString, true);
}
/**
1.7 +26 -0
jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java
Index: Task.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- Task.java 25 Feb 2002 13:28:57 -0000 1.6
+++ Task.java 26 Feb 2002 13:43:54 -0000 1.7
@@ -131,6 +131,32 @@
return description;
}
+
+ /**
+ * XXX Adds a feature to the NestedTask attribute of the Task object
+ *
+ * @param task XXX The feature to be added to the NestedTask attribute
+ * @exception ExecutionException XXX Description of Exception
+ */
+ public void addNestedTask(org.apache.ant.common.antlib.Task task)
+ throws ExecutionException {
+
+ if (!(this instanceof TaskContainer)) {
+ throw new BuildException("Can't add tasks to this task");
+ }
+ // wrap the Ant2 task in a TaskAdapter
+ TaskContainer container = (TaskContainer)this;
+ if (task instanceof Task) {
+ container.addTask((Task)task);
+ } else {
+ TaskAdapter adapter = new TaskAdapter();
+ adapter.setProxy(task);
+ adapter.setProject(getProject());
+ adapter.init(task.getAntContext(), task.getComponentType());
+ container.addTask(adapter);
+ }
+ }
+
/**
* Initialise this component
*
1.2 +8 -1
jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/TaskContainer.java
Index: TaskContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/TaskContainer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- TaskContainer.java 2 Feb 2002 14:50:32 -0000 1.1
+++ TaskContainer.java 26 Feb 2002 13:43:54 -0000 1.2
@@ -59,6 +59,13 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 31 January 2002
*/
-public interface TaskContainer {
+public interface TaskContainer
+ extends org.apache.ant.common.antlib.TaskContainer {
+ /**
+ * Add a task to this container
+ *
+ * @param task the task to be added
+ */
+ void addTask(Task task);
}
1.5 +3 -0
jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml
Index: antlib.xml
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/antlibs/system/antlib.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- antlib.xml 11 Feb 2002 15:42:18 -0000 1.4
+++ antlib.xml 26 Feb 2002 13:43:54 -0000 1.5
@@ -7,6 +7,9 @@
<taskdef name="ant" classname="org.apache.ant.antlib.system.Ant"/>
<taskdef name="antcall" classname="org.apache.ant.antlib.system.AntCall"/>
+
+<!-- <taskdef name="parallel"
classname="org.apache.ant.antlib.system.Parallel"/>
+ <taskdef name="sequential"
classname="org.apache.ant.antlib.system.Sequential"/> -->
<converter classname="org.apache.ant.antlib.system.FileConverter"/>
<converter classname="org.apache.ant.antlib.system.URLConverter"/>
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Parallel.java
Index: Parallel.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.TaskContainer;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.util.Location;
/**
* Implements a multi threaded task execution.
*
* @author Thomas Christen <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill </a>
* @created 27 February 2002
*/
public class Parallel extends AbstractTask
implements TaskContainer {
/**
* Class which stores information about the thread to which each task is
* associated
*
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @created 27 February 2002
*/
private class TaskThread extends Thread {
/** The exception thrown, if any, by the task running in this thread
*/
private Throwable exception;
/** The task running is this thread */
private Task task;
/** An identifier for the thread */
private int taskNumber;
/**
* Construct a new TaskThread
*
* @param task the Task to be executed in a seperate thread
* @param taskNumber the thread's identifier
*/
TaskThread(int taskNumber, Task task) {
this.task = task;
this.taskNumber = taskNumber;
}
/**
* Get the exception thrown by the task, if any.
*
* @return the Throwable instance thrown by the task or null if
* nothing was thrown.
*/
public Throwable getException() {
return exception;
}
/**
* Executes the task within a thread and takes care about Exceptions
* raised within the task.
*/
public void run() {
try {
AntContext context = getAntContext();
ExecService execService
= (ExecService)context.getCoreService(ExecService.class);
execService.executeTask(task);
} catch (Throwable t) {
exception = t;
}
}
}
/** Collection holding the nested tasks */
private List nestedTasks = new ArrayList();
/**
* Add a nested task to execute parallel (asynchron).
*
* @param nestedTask Nested task to be executed in parallel
*/
public void addNestedTask(Task nestedTask) {
nestedTasks.add(nestedTask);
}
/**
* Block execution until the specified time or for a specified amount of
* milliseconds and if defined, execute the wait status.
*
* @exception ExecutionException if any of the nested tasks throws an
* exception
*/
public void execute() throws ExecutionException {
TaskThread[] threads = new TaskThread[nestedTasks.size()];
int threadNumber = 0;
for (Iterator i = nestedTasks.iterator(); i.hasNext();
threadNumber++) {
Task nestedTask = (Task)i.next();
threads[threadNumber] = new TaskThread(threadNumber, nestedTask);
}
// now start all threads
for (int i = 0; i < threads.length; ++i) {
threads[i].start();
}
// now join to all the threads
for (int i = 0; i < threads.length; ++i) {
try {
threads[i].join();
} catch (InterruptedException ie) {
// who would interrupt me at a time like this?
}
}
// now did any of the threads throw an exception
StringBuffer exceptionMessage = new StringBuffer();
String lSep = System.getProperty("line.separator");
int numExceptions = 0;
Throwable firstException = null;
Location firstLocation = Location.UNKNOWN_LOCATION;
for (int i = 0; i < threads.length; ++i) {
Throwable t = threads[i].getException();
if (t != null) {
numExceptions++;
if (firstException == null) {
firstException = t;
}
if (t instanceof ExecutionException &&
firstLocation == Location.UNKNOWN_LOCATION) {
firstLocation = ((ExecutionException)t).getLocation();
}
exceptionMessage.append(lSep);
exceptionMessage.append(t.getMessage());
}
}
if (numExceptions == 1) {
if (firstException instanceof ExecutionException) {
throw (ExecutionException)firstException;
} else {
throw new ExecutionException(firstException);
}
} else if (numExceptions > 1) {
throw new ExecutionException(exceptionMessage.toString(),
firstLocation);
}
}
}
1.1
jakarta-ant/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Sequential.java
Index: Sequential.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.ant.antlib.system;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.ant.common.antlib.AbstractTask;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.Task;
import org.apache.ant.common.antlib.TaskContainer;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.ExecutionException;
/**
* Implements a single threaded task execution. <p>
*
*
*
* @author Thomas Christen <a href="mailto:[EMAIL PROTECTED]">[EMAIL
PROTECTED]</a>
* @created 27 February 2002
*/
public class Sequential extends AbstractTask
implements TaskContainer {
/** Collection holding the nested tasks */
private List nestedTasks = new ArrayList();
/**
* Add a nested task to Sequential. <p>
*
*
*
* @param nestedTask Nested task to execute Sequential <p>
*
*
*/
public void addNestedTask(Task nestedTask) {
nestedTasks.add(nestedTask);
}
/**
* Execute all nestedTasks.
*
* @exception ExecutionException if any of the nested tasks throws an
* exception
*/
public void execute() throws ExecutionException {
AntContext context = getAntContext();
ExecService execService
= (ExecService)context.getCoreService(ExecService.class);
for (Iterator i = nestedTasks.iterator(); i.hasNext(); ) {
Task nestedTask = (Task)i.next();
execService.executeTask(nestedTask);
}
}
}
1.2 +1 -1
jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/TaskContainer.java
Index: TaskContainer.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/mutant/src/java/common/org/apache/ant/common/antlib/TaskContainer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- TaskContainer.java 2 Feb 2002 14:50:33 -0000 1.1
+++ TaskContainer.java 26 Feb 2002 13:43:54 -0000 1.2
@@ -67,6 +67,6 @@
* @param task the task tobe added
* @exception ExecutionException if the container cannot add the task
*/
- void addTask(Task task) throws ExecutionException;
+ void addNestedTask(Task task) throws ExecutionException;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>