diff --git a/proposal/mutant/build.xml b/proposal/mutant/build.xml
index 5cf5a250a..8af8e9462 100644
--- a/proposal/mutant/build.xml
+++ b/proposal/mutant/build.xml
@@ -155,7 +155,7 @@
-
+
diff --git a/proposal/mutant/build/ant1compat.xml b/proposal/mutant/build/ant1compat.xml
index 2fefd772c..ad900cbb4 100644
--- a/proposal/mutant/build/ant1compat.xml
+++ b/proposal/mutant/build/ant1compat.xml
@@ -66,7 +66,7 @@
-
+
diff --git a/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreFileService.java b/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreFileService.java
index 8285fcfce..f659e9347 100644
--- a/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreFileService.java
+++ b/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/CoreFileService.java
@@ -69,7 +69,7 @@ public class CoreFileService implements FileService {
private Frame frame;
/** General file utilities */
- private FileUtils fileUtils = new FileUtils();
+ private FileUtils fileUtils = FileUtils.newFileUtils();
/**
* Constructor
diff --git a/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java b/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
index 272c94319..d1609ca3a 100644
--- a/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
+++ b/proposal/mutant/src/java/antcore/org/apache/ant/antcore/execution/Frame.java
@@ -744,7 +744,7 @@ public class Frame implements DemuxOutputReceiver {
if (base == null) {
baseDir = projectFileParent;
} else {
- FileUtils fileUtils = new FileUtils();
+ FileUtils fileUtils = FileUtils.newFileUtils();
baseDir = fileUtils.resolveFile(projectFileParent, base);
}
} else {
diff --git a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
index 90a59a218..ac2079130 100644
--- a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
+++ b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Project.java
@@ -64,11 +64,11 @@ import java.util.Stack;
import java.util.Vector;
import org.apache.ant.common.antlib.AntContext;
import org.apache.ant.common.antlib.AntLibFactory;
+import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.service.ComponentService;
import org.apache.ant.common.service.DataService;
import org.apache.ant.common.service.FileService;
import org.apache.ant.common.util.ExecutionException;
-import org.apache.ant.common.event.MessageLevel;
import org.apache.ant.common.util.PropertyUtils;
import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
@@ -83,42 +83,44 @@ import org.apache.tools.ant.util.FileUtils;
public class Project implements org.apache.ant.common.event.BuildListener {
/** String which indicates Java version 1.0 */
- public static final String JAVA_1_0 = "1.0";
+ public final static String JAVA_1_0 = "1.0";
/** String which indicates Java version 1.1 */
- public static final String JAVA_1_1 = "1.1";
+ public final static String JAVA_1_1 = "1.1";
/** String which indicates Java version 1.2 */
- public static final String JAVA_1_2 = "1.2";
+ public final static String JAVA_1_2 = "1.2";
/** String which indicates Java version 1.3 */
- public static final String JAVA_1_3 = "1.3";
+ public final static String JAVA_1_3 = "1.3";
/** String which indicates Java version 1.4 */
- public static final String JAVA_1_4 = "1.4";
+ public final static String JAVA_1_4 = "1.4";
/**
* @see MessageLevel.MSG_ERR
*/
- public static final int MSG_ERR = MessageLevel.MSG_ERR;
+ public final static int MSG_ERR = MessageLevel.MSG_ERR;
/**
* @see MessageLevel.MSG_WARN
*/
- public static final int MSG_WARN = MessageLevel.MSG_WARN;
+ public final static int MSG_WARN = MessageLevel.MSG_WARN;
/**
* @see MessageLevel.MSG_INFO
*/
- public static final int MSG_INFO = MessageLevel.MSG_INFO;
+ public final static int MSG_INFO = MessageLevel.MSG_INFO;
/**
* @see MessageLevel.MSG_VERBOSE
*/
- public static final int MSG_VERBOSE = MessageLevel.MSG_VERBOSE;
+ public final static int MSG_VERBOSE = MessageLevel.MSG_VERBOSE;
/**
* @see MessageLevel.MSG_DEBUG
*/
- public static final int MSG_DEBUG = MessageLevel.MSG_DEBUG;
+ public final static int MSG_DEBUG = MessageLevel.MSG_DEBUG;
/** The java version detected that Ant is running on */
private static String javaVersion;
- /** the factory which created this project instance. This is used to
- define new types and tasks */
+ /**
+ * the factory which created this project instance. This is used to
+ * define new types and tasks
+ */
private AntLibFactory factory;
/** Collection of Ant1 type definitions */
@@ -199,14 +201,6 @@ public class Project implements org.apache.ant.common.event.BuildListener {
return javaVersion;
}
- /**
- * get the target hashtable
- * @return hashtable, the contents of which can be cast to Target
- */
- public Hashtable getTargets() {
- return new Hashtable(); // XXX can't get targets
- }
-
/**
* returns the boolean equivalent of a string, which is considered true
* if either "on", "true", or "yes" is found, ignoring case.
@@ -302,6 +296,24 @@ public class Project implements org.apache.ant.common.event.BuildListener {
}
}
+ /**
+ * Gets the Antlib factory of the Project
+ *
+ * @return The project's associated factory object
+ */
+ public AntLibFactory getFactory() {
+ return factory;
+ }
+
+ /**
+ * get the target hashtable
+ *
+ * @return hashtable, the contents of which can be cast to Target
+ */
+ public Hashtable getTargets() {
+ return new Hashtable();// XXX can't get targets
+ }
+
/**
* Gets the buildListeners of the Project
*
@@ -878,7 +890,7 @@ public class Project implements org.apache.ant.common.event.BuildListener {
}
try {
- Object taskObject = componentService.createComponent(factory,
+ Object taskObject = componentService.createComponent(factory,
context.getClassLoader(), taskClass, false, taskType);
if (taskObject instanceof Task) {
task = (Task)taskObject;
@@ -897,15 +909,13 @@ public class Project implements org.apache.ant.common.event.BuildListener {
/**
* Creates a new instance of a data type.
- *
+ *
* @param typeName The name of the data type to create an instance of.
- * Must not be null
.
- *
- * @return an instance of the specified data type, or null
if
- * the data type name is not recognised.
- *
- * @exception BuildException if the data type name is recognised but
- * instance creation fails.
+ * Must not be null
.
+ * @return an instance of the specified data type, or null
+ * if the data type name is not recognised.
+ * @exception BuildException if the data type name is recognised but
+ * instance creation fails.
*/
public Object createDataType(String typeName) throws BuildException {
Class typeClass = (Class)dataClassDefinitions.get(typeName);
@@ -915,14 +925,14 @@ public class Project implements org.apache.ant.common.event.BuildListener {
}
try {
- Object dataInstance = componentService.createComponent(factory,
+ Object dataInstance = componentService.createComponent(factory,
context.getClassLoader(), typeClass, false, typeName);
return dataInstance;
} catch (Throwable e) {
throw new BuildException(e);
}
}
-
+
/** send build started event to the listeners */
protected void fireBuildStarted() {
BuildEvent event = new BuildEvent(this);
diff --git a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java
index 4659b5ef9..5cdddb468 100644
--- a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java
+++ b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/Task.java
@@ -170,6 +170,7 @@ public abstract class Task extends ProjectComponent
taskType = componentType;
taskName = componentType;
+ init();
}
diff --git a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java
index 65afba577..d51cced57 100644
--- a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java
+++ b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/Ant.java
@@ -52,6 +52,17 @@
* .
*/
package org.apache.tools.ant.taskdefs;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.ant.antlib.system.AntBase;
+import org.apache.ant.common.antlib.AntContext;
+import org.apache.ant.common.antlib.AntLibFactory;
+import org.apache.ant.common.service.ComponentService;
+import org.apache.ant.common.util.ExecutionException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
/**
* Ant facade over system version of Ant
@@ -59,6 +70,146 @@ package org.apache.tools.ant.taskdefs;
* @author Conor MacNeill
* @created 31 January 2002
*/
-public class Ant extends org.apache.ant.antlib.system.Ant {
+public class Ant extends Task {
+ /** The core Ant implementation to actually use */
+ private org.apache.ant.antlib.system.Ant realAnt = null;
+
+ /** The properties created by this task */
+ private List properties = new ArrayList();
+
+ /**
+ * If true, inherit all properties from parent Project If false, inherit
+ * only userProperties and those defined inside the ant call itself
+ *
+ * @param value true if the sub-build should receive all properties from
+ * this build
+ */
+ public void setInheritAll(boolean value) {
+ realAnt.setInheritAll(value);
+ }
+
+ /**
+ * If true, inherit all references from parent Project If false, inherit
+ * only those defined inside the ant call itself
+ *
+ * @param value true if the subbuild should receive all references from
+ * the current build.
+ */
+ public void setInheritRefs(boolean value) {
+ realAnt.setInheritRefs(value);
+ }
+
+ /**
+ * The directory which will be the base directory for the build
+ *
+ * @param d the base directory for the new build
+ */
+ public void setDir(File d) {
+ realAnt.setDir(d);
+ }
+
+ /**
+ * set the build file, it can be either absolute or relative. If it is
+ * absolute, dir will be ignored, if it is relative it will be
+ * resolved relative to dir .
+ *
+ * @param s the name of the ant file either absolute or relative to the
+ * sub-build's basedir
+ */
+ public void setAntfile(String s) {
+ realAnt.setAntFile(s);
+ }
+
+ /**
+ * set the target to execute. If none is defined it will execute the
+ * default target of the build file
+ *
+ * @param s the target to eb executed in the sub-build
+ */
+ public void setTarget(String s) {
+ realAnt.setTarget(s);
+ }
+
+ /**
+ * XXX Sets the output of the Ant
+ *
+ * @param s name of the file to store output.
+ */
+ public void setOutput(String s) {
+ // realAnt.setOutput(s);
+ }
+
+ /** Initialize the task */
+ public void init() {
+ AntContext context = getAntContext();
+ try {
+ ComponentService componentService = getComponentService();
+ AntLibFactory factory = getProject().getFactory();
+ realAnt = (org.apache.ant.antlib.system.Ant)
+ componentService.createComponent(factory,
+ context.getClassLoader(),
+ org.apache.ant.antlib.system.Ant.class, false, "antcall");
+ } catch (ExecutionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+
+ /**
+ * Do the execution.
+ *
+ * @exception BuildException XXX Description of Exception
+ */
+ public void execute() throws BuildException {
+ for (Iterator i = properties.iterator(); i.hasNext(); ) {
+ Property property = (Property)i.next();
+ AntBase.Property newProperty = new AntBase.Property();
+ newProperty.setName(property.getName());
+ newProperty.setValue(property.getValue());
+ realAnt.addProperty(newProperty);
+ }
+ try {
+ realAnt.execute();
+ } catch (ExecutionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * Create a nested property element.
+ *
+ * @return the Property object to be configured.
+ */
+ public Property createProperty() {
+ Property property = new Property();
+ properties.add(property);
+ return property;
+ }
+
+ /**
+ * create a reference element that identifies a data type that should be
+ * carried over to the new project.
+ *
+ * @param r the reference to be added to the call
+ */
+ public void addReference(AntBase.Reference r) {
+ try {
+ realAnt.addReference(r);
+ } catch (ExecutionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * Gets the componentService
+ *
+ * @return the componentService instance provided by the core
+ * @exception ExecutionException if the service is not available.
+ */
+ private ComponentService getComponentService() throws ExecutionException {
+ AntContext context = getAntContext();
+ return (ComponentService)context.getCoreService(ComponentService.class);
+ }
+
}
diff --git a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java
index b491520cf..8d75a2715 100644
--- a/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java
+++ b/proposal/mutant/src/java/antlibs/ant1compat/org/apache/tools/ant/taskdefs/CallTarget.java
@@ -52,8 +52,17 @@
* .
*/
package org.apache.tools.ant.taskdefs;
-
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.ant.antlib.system.AntBase;
import org.apache.ant.antlib.system.AntCall;
+import org.apache.ant.common.antlib.AntContext;
+import org.apache.ant.common.antlib.AntLibFactory;
+import org.apache.ant.common.service.ComponentService;
+import org.apache.ant.common.util.ExecutionException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
/**
* CallTarget facade over AntCall
@@ -61,6 +70,95 @@ import org.apache.ant.antlib.system.AntCall;
* @author Conor MacNeill
* @created 31 January 2002
*/
-public class CallTarget extends AntCall {
+public class CallTarget extends Task {
+ /** The core AntCall implementation to actually use */
+ private AntCall antCall = null;
+
+ /** The properties created by this task */
+ private List properties = new ArrayList();
+
+ /**
+ * If true, inherit all properties from parent Project If false, inherit
+ * only userProperties and those defined inside the antcall call itself
+ *
+ * @param inherit the new inheritAll value
+ */
+ public void setInheritAll(boolean inherit) {
+ antCall.setInheritAll(inherit);
+ }
+
+ /**
+ * Sets the target of the CallTarget
+ *
+ * @param target the new target value
+ */
+ public void setTarget(String target) {
+ antCall.setTarget(target);
+ }
+
+ /** Initialize the task */
+ public void init() {
+ AntContext context = getAntContext();
+ try {
+ ComponentService componentService = getComponentService();
+ AntLibFactory factory = getProject().getFactory();
+ antCall = (AntCall)componentService.createComponent(factory,
+ context.getClassLoader(), AntCall.class, false, "antcall");
+ } catch (ExecutionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /** execute the call */
+ public void execute() {
+ for (Iterator i = properties.iterator(); i.hasNext(); ) {
+ Property property = (Property)i.next();
+ AntBase.Property newProperty = new AntBase.Property();
+ newProperty.setName(property.getName());
+ newProperty.setValue(property.getValue());
+ antCall.addProperty(newProperty);
+ }
+ try {
+ antCall.execute();
+ } catch (ExecutionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * Create a nested param element.
+ *
+ * @return the Property object to be configured.
+ */
+ public Property createParam() {
+ Property property = new Property();
+ properties.add(property);
+ return property;
+ }
+
+ /**
+ * create a reference element that identifies a data type that should be
+ * carried over to the new project.
+ *
+ * @param r the reference to be added to the call
+ */
+ public void addReference(AntBase.Reference r) {
+ try {
+ antCall.addReference(r);
+ } catch (ExecutionException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ /**
+ * Gets the componentService
+ *
+ * @return the componentService instance provided by the core
+ * @exception ExecutionException if the service is not available.
+ */
+ private ComponentService getComponentService() throws ExecutionException {
+ AntContext context = getAntContext();
+ return (ComponentService)context.getCoreService(ComponentService.class);
+ }
}
diff --git a/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java b/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java
index 73f9a48ba..942f80692 100644
--- a/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java
+++ b/proposal/mutant/src/java/antlibs/system/org/apache/ant/antlib/system/Ant.java
@@ -56,6 +56,7 @@ import java.io.File;
import org.apache.ant.common.service.ExecService;
import org.apache.ant.common.util.ExecutionException;
import org.apache.ant.common.service.MagicProperties;
+import org.apache.ant.common.util.FileUtils;
/**
* The Ant task - used to execute a different build file
@@ -65,7 +66,7 @@ import org.apache.ant.common.service.MagicProperties;
*/
public class Ant extends AntBase {
/** The ant file to be run */
- private File antFile;
+ private String antFileName;
/** the base directory to use for the run */
private File baseDir;
/** File to capture any output */
@@ -74,10 +75,10 @@ public class Ant extends AntBase {
/**
* sets the file containing the XML representation model to build
*
- * @param antFile the file to build
+ * @param antFileName the file to build
*/
- public void setAntFile(File antFile) {
- this.antFile = antFile;
+ public void setAntFile(String antFileName) {
+ this.antFileName = antFileName;
}
/**
@@ -107,12 +108,18 @@ public class Ant extends AntBase {
if (baseDir == null) {
baseDir = getAntContext().getBaseDir();
}
- if (antFile == null) {
+
+ File antFile = null;
+ if (antFileName == null) {
antFile = new File(baseDir, "build.ant");
if (!antFile.exists()) {
antFile = new File(baseDir, "build.xml");
}
+ } else {
+ antFile
+ = FileUtils.newFileUtils().resolveFile(baseDir, antFileName);
}
+
setProperty(MagicProperties.BASEDIR, baseDir.getAbsolutePath());
ExecService execService
diff --git a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Ant1CompatBuilder.java b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Ant1CompatBuilder.java
index fcc8a48ac..441f09742 100644
--- a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Ant1CompatBuilder.java
+++ b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Ant1CompatBuilder.java
@@ -21,7 +21,7 @@ public class Ant1CompatBuilder {
"${lib.dir}/ant1compat", "*.jar");
helper.addPathElementToPath("classpath", "${distlib.dir}/init.jar");
helper.addPathElementToPath("classpath", "${distlib.dir}/common/common.jar");
- helper.addPathElementToPath("classpath", "${distlib.dir}/antlibs/system.tsk");
+ helper.addPathElementToPath("classpath", "${distlib.dir}/antlibs/system.jar");
}
protected void check_for_optional_packages(BuildHelper helper) {
}
diff --git a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java
index bf794f316..f1e04c643 100644
--- a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java
+++ b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/MutantBuilder.java
@@ -83,7 +83,7 @@ public class MutantBuilder {
helper.addPathElementToPath("classpath.antlibs", "${distlib.dir}/common/common.jar");
helper.addPathToPath("classpath.antlibs", "classpath.common");
helper.javac("${java.dir}/antlibs/${libset}", "${bin.dir}/antlibs/${libset}", "classpath.antlibs");
- helper.jar("${bin.dir}/antlibs/${libset}", "${distlib.dir}/antlibs/${libset}.tsk",
+ helper.jar("${bin.dir}/antlibs/${libset}", "${distlib.dir}/antlibs/${libset}.jar",
"${java.dir}/antlibs/${libset}", "antlib.xml");
}
protected void main(BuildHelper helper) {
diff --git a/proposal/mutant/src/java/common/org/apache/ant/common/util/FileUtils.java b/proposal/mutant/src/java/common/org/apache/ant/common/util/FileUtils.java
index a326e0bad..e148e1620 100644
--- a/proposal/mutant/src/java/common/org/apache/ant/common/util/FileUtils.java
+++ b/proposal/mutant/src/java/common/org/apache/ant/common/util/FileUtils.java
@@ -68,6 +68,21 @@ import java.util.StringTokenizer;
* @created 21 January 2002
*/
public class FileUtils {
+
+ /** Empty constructor. */
+ protected FileUtils() {
+ }
+
+ /**
+ * Factory method.
+ *
+ * @return The FileUtils instance to actually use. May be a subclass of
+ * this class.
+ */
+ public static FileUtils newFileUtils() {
+ return new FileUtils();
+ }
+
/**
* Interpret the filename as a file relative to the given file - unless
* the filename already represents an absolute filename.
@@ -76,8 +91,7 @@ public class FileUtils {
* must be an absolute file and must not contain "./" or
* "../" sequences (same for \ instead of /). If it is
* null, this call is equivalent to
- * new java.io.File(filename)
- * .
+ * new java.io.File(filename)
.
* @param filename the filename to be resolved
* @return an absolute file that doesn't contain "./" or
* "../" sequences and uses the correct separator for the
@@ -102,8 +116,8 @@ public class FileUtils {
}
File helpFile = new File(file.getAbsolutePath());
- StringTokenizer tok
- = new StringTokenizer(platformFilename, File.separator);
+ StringTokenizer tok
+ = new StringTokenizer(platformFilename, File.separator);
while (tok.hasMoreTokens()) {
String part = tok.nextToken();
if (part.equals("..")) {