diff --git a/proposal/mutant/bootstrap.bat b/proposal/mutant/bootstrap.bat
index 26c57f75d..57c62ec56 100755
--- a/proposal/mutant/bootstrap.bat
+++ b/proposal/mutant/bootstrap.bat
@@ -23,10 +23,10 @@ REM run bootstrap
java -classpath bin\init;bin\bootstrap org.apache.ant.bootstrap.Bootstrap
REM run full build using bootstrapped version
-java -classpath bootstrap\lib\start.jar;bootstrap\lib\init.jar org.apache.ant.start.Main %*
+java -jar bootstrap\lib\start.jar %*
REM Use the full build as the build used by the build script
xcopy /s dist bootstrap
REM clean up after bootstrap
-java -classpath bootstrap\lib\start.jar:bootstrap\lib\init.jar org.apache.ant.start.Main clean
+java -jar bootstrap\lib\start.jar clean
diff --git a/proposal/mutant/bootstrap.sh b/proposal/mutant/bootstrap.sh
index 2d0ddfe6a..2e096a9ca 100755
--- a/proposal/mutant/bootstrap.sh
+++ b/proposal/mutant/bootstrap.sh
@@ -22,10 +22,10 @@ javac -classpath bin/init:bin/bootstrap -d bin/builder src/java/bootstrap/org/ap
java -classpath bin/init:bin/bootstrap org.apache.ant.bootstrap.Bootstrap
# run full build using bootstrapped version
-java -classpath bootstrap/lib/start.jar:bootstrap/lib/init.jar org.apache.ant.start.Main $*
+java -jar bootstrap/lib/start.jar $*
# Use the full build as the build used by the build script
cp -r dist/lib bootstrap
#clean up after bootstrap
-java -classpath bootstrap/lib/start.jar:bootstrap/lib/init.jar org.apache.ant.start.Main clean
+java -jar bootstrap/lib/start.jar clean
diff --git a/proposal/mutant/build.bat b/proposal/mutant/build.bat
index 8360aabd1..173f649fb 100755
--- a/proposal/mutant/build.bat
+++ b/proposal/mutant/build.bat
@@ -1,5 +1,5 @@
@echo off
-REM Copyright (c) 2000-2001 The Apache Software Foundation. All rights
+REM Copyright (c) 2002 The Apache Software Foundation. All rights
REM reserved.
-java -classpath bootstrap\lib\start.jar;bootstrap\lib\init.jar org.apache.ant.start.Main %*
+java -jar bootstrap\lib\start.jar %*
diff --git a/proposal/mutant/build.sh b/proposal/mutant/build.sh
index 753bef805..d2cc21394 100755
--- a/proposal/mutant/build.sh
+++ b/proposal/mutant/build.sh
@@ -1,6 +1,6 @@
#!/bin/sh -x
-# Copyright (c) 2000-2001 The Apache Software Foundation. All rights
+# Copyright (c) 2002 The Apache Software Foundation. All rights
# reserved.
-java -classpath bootstrap/lib/start.jar:bootstrap/lib/init.jar org.apache.ant.start.Main $@
+java -jar bootstrap/lib/start.jar $@
diff --git a/proposal/mutant/build.xml b/proposal/mutant/build.xml
index eb78fc0df..5e1c62b5f 100644
--- a/proposal/mutant/build.xml
+++ b/proposal/mutant/build.xml
@@ -25,7 +25,7 @@
-
+
@@ -75,18 +75,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
+
+
+
@@ -165,7 +170,7 @@
-
+
");
+
+
+
helper.createPath("
");
+
helper.addFileSetToPath("
@@ -48,6 +52,7 @@
);
+
helper.addPathElementToPath("
@@ -56,6 +61,7 @@
");
+
helper.addPathToPath("
@@ -114,17 +120,33 @@
"
- "
+ ",
- null
+ null,
- null, null
+ null, null,
+
+
+ "
+
+ ",
+
+ null,
+
+
+
+ "
+
+ "
+
+ null
+
);
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 aa938727f..e38018420 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
@@ -37,7 +37,7 @@ public class Ant1CompatBuilder {
helper.copyFileset("${bin.dir}/ant1src_copy", "${bin.dir}/ant1compat");
helper.copyFileset("${ant1etc.dir}", "${bin.dir}/ant1compat/${optional.package}/junit/xsl");
helper.jar("${bin.dir}/ant1compat", "${distlib.dir}/antlibs/ant1compat.jar",
- "${java.dir}/antlibs/ant1compat", "antlib.xml");
+ "${java.dir}/antlibs/ant1compat", "antlib.xml", null, null);
}
protected void clean(BuildHelper helper) {
}
diff --git a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/BuildHelper.java b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/BuildHelper.java
index 6e6974f1f..5131ddada 100644
--- a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/BuildHelper.java
+++ b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/BuildHelper.java
@@ -64,7 +64,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.jar.Attributes;
import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
/**
@@ -90,6 +92,7 @@ public class BuildHelper {
}
+
/** The properties which have been defined in the build */
private Map properties = new HashMap();
@@ -99,6 +102,7 @@ public class BuildHelper {
/** Filesets created in the build */
private Map filesets = new HashMap();
+
/**
* Set a property for the build
*
@@ -108,30 +112,49 @@ public class BuildHelper {
protected void setProperty(String propertyName, String propertyValue) {
if (!properties.containsKey(propertyName)) {
String value = resolve(propertyValue);
+
properties.put(propertyName, value);
}
}
+
/**
* Create a Jar
*
* @param basedir the base directpory from which files are added to the
* jar
* @param metaInfDir the directory containing the META-INF for the jar
- * @param metaInfIncludes the files to be included in the META-INF area
- * of the jar
+ * @param metaInfIncludes the files to be included in the META-INF area of
+ * the jar
* @param jarFile the file in which the Jar is created
+ * @param classpath Class-Path attribute in manifest
+ * @param mainClass Main-Class attribute in manifest
*/
protected void jar(String basedir, String jarFile, String metaInfDir,
- String metaInfIncludes) {
+ String metaInfIncludes,
+ String classpath, String mainClass) {
try {
File base = new File(resolve(basedir));
File jar = new File(resolve(jarFile));
+ Manifest manifest = new Manifest();
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.putValue("Manifest-Version", "1.0");
+ attributes.putValue("Created-By", "Mutant Bootstrap");
+
+ if (classpath != null) {
+ attributes.putValue("Class-Path", classpath);
+ }
+ if (mainClass != null) {
+ attributes.putValue("Main-Class", mainClass);
+ }
+
JarOutputStream jos
- = new JarOutputStream(new FileOutputStream(jar));
+ = new JarOutputStream(new FileOutputStream(jar), manifest);
+
addToJar(jos, base, null);
if (metaInfDir != null) {
File[] metaFileSet = buildFileSet(metaInfDir, metaInfIncludes);
+
addFilesToJar(jos, new File(resolve(metaInfDir)),
metaFileSet, "META-INF");
}
@@ -142,38 +165,44 @@ public class BuildHelper {
}
}
+
/**
* Compile a set of files
*
* @param srcDir the source directory
* @param destDir where the compiled classes will go
- * @param classpathRef the id of a path object with the classpath for
- * the build
+ * @param classpathRef the id of a path object with the classpath for the
+ * build
*/
protected void javac(String srcDir, String destDir, String classpathRef) {
List javaFiles = new ArrayList();
String src = resolve(srcDir);
StringTokenizer tokenizer = new StringTokenizer(src, ":");
+
while (tokenizer.hasMoreTokens()) {
File srcLocation = new File(tokenizer.nextToken());
+
getJavaFiles(srcLocation, javaFiles);
}
File dest = new File(resolve(destDir));
int numArgs = javaFiles.size() + 2;
+
if (classpathRef != null) {
numArgs += 2;
}
String[] args = new String[numArgs];
int index = 0;
+
args[index++] = "-d";
args[index++] = dest.getPath();
if (classpathRef != null) {
String path = (String) paths.get(resolve(classpathRef));
+
args[index++] = "-classpath";
args[index++] = path;
}
- for (Iterator i = javaFiles.iterator(); i.hasNext();) {
+ for (Iterator i = javaFiles.iterator(); i.hasNext(); ) {
args[index++] = ((File) i.next()).getPath();
}
@@ -182,6 +211,7 @@ public class BuildHelper {
Object compiler = c.newInstance();
Method compile = c.getMethod("compile",
new Class[]{(new String[]{}).getClass()});
+
compile.invoke(compiler, new Object[]{args});
} catch (Exception e) {
e.printStackTrace();
@@ -189,6 +219,7 @@ public class BuildHelper {
}
}
+
/**
* Copy a directory
*
@@ -198,9 +229,11 @@ public class BuildHelper {
protected void copyFileset(String fromDir, String toDir) {
File from = new File(resolve(fromDir));
File to = new File(resolve(toDir));
+
copyDir(from, to);
}
+
/**
* Add a fileset to this build helper
*
@@ -210,11 +243,13 @@ public class BuildHelper {
*/
protected void addFileSet(String name, File root, File[] files) {
FileSetInfo info = new FileSetInfo();
+
info.root = root;
info.files = files;
filesets.put(name, info);
}
+
/**
* Copy a fileset given a reference to the source fileset
*
@@ -223,12 +258,15 @@ public class BuildHelper {
*/
protected void copyFilesetRef(String fileSetRef, String toDir) {
FileSetInfo fileset = (FileSetInfo) filesets.get(resolve(fileSetRef));
+
if (fileset != null) {
File to = new File(resolve(toDir));
+
copyFileList(fileset.root, fileset.files, to);
}
}
+
/**
* Make a directory
*
@@ -236,9 +274,11 @@ public class BuildHelper {
*/
protected void mkdir(String dirName) {
File dir = new File(resolve(dirName));
+
dir.mkdirs();
}
+
/**
* Create a path object
*
@@ -246,9 +286,11 @@ public class BuildHelper {
*/
protected void createPath(String pathName) {
String path = "";
+
paths.put(pathName, path);
}
+
/**
* Add a fileset to a path
*
@@ -260,6 +302,7 @@ public class BuildHelper {
String filesetIncludes) {
File[] files = buildFileSet(filesetDir, filesetIncludes);
String currentPath = (String) paths.get(pathName);
+
for (int i = 0; i < files.length; ++i) {
if (currentPath == null || currentPath.length() == 0) {
currentPath = files[i].getPath();
@@ -271,6 +314,7 @@ public class BuildHelper {
paths.put(pathName, currentPath);
}
+
/**
* Add a new element to a path
*
@@ -280,6 +324,7 @@ public class BuildHelper {
protected void addPathElementToPath(String pathName, String location) {
String pathElement = resolve(location).replace('/', File.separatorChar);
String currentPath = (String) paths.get(pathName);
+
if (currentPath == null || currentPath.length() == 0) {
currentPath = pathElement;
} else {
@@ -288,6 +333,7 @@ public class BuildHelper {
paths.put(pathName, currentPath);
}
+
/**
* Add an existing path to another path
*
@@ -296,11 +342,13 @@ public class BuildHelper {
*/
protected void addPathToPath(String pathName, String pathNameToAdd) {
String pathToAdd = (String) paths.get(pathNameToAdd);
+
if (pathToAdd == null || pathToAdd.length() == 0) {
return;
}
String currentPath = (String) paths.get(pathName);
+
if (currentPath == null || currentPath.length() == 0) {
currentPath = pathToAdd;
} else {
@@ -309,6 +357,7 @@ public class BuildHelper {
paths.put(pathName, currentPath);
}
+
/**
* Get the set of Java files to be compiled
*
@@ -317,6 +366,7 @@ public class BuildHelper {
*/
private void getJavaFiles(File srcDir, List javaFiles) {
File[] files = srcDir.listFiles();
+
for (int i = 0; i < files.length; ++i) {
if (files[i].isDirectory()) {
getJavaFiles(files[i], javaFiles);
@@ -326,6 +376,7 @@ public class BuildHelper {
}
}
+
/**
* Copy a file
*
@@ -340,6 +391,7 @@ public class BuildHelper {
FileOutputStream out = new FileOutputStream(dest);
byte[] buf = new byte[1024 * 16];
int count = 0;
+
count = in.read(buf, 0, buf.length);
while (count != -1) {
out.write(buf, 0, count);
@@ -355,6 +407,7 @@ public class BuildHelper {
}
}
+
/**
* Copy a list of files from one directory to another, preserving the
* relative paths
@@ -371,6 +424,7 @@ public class BuildHelper {
String name
= files[i].getPath().substring(root.getPath().length() + 1);
File dest = new File(to, name);
+
if (files[i].isDirectory()) {
copyDir(files[i], dest);
} else {
@@ -379,6 +433,7 @@ public class BuildHelper {
}
}
+
/**
* Copy a directory
*
@@ -387,10 +442,13 @@ public class BuildHelper {
*/
private void copyDir(File from, File to) {
to.mkdirs();
+
File[] files = from.listFiles();
+
copyFileList(from, files, to);
}
+
/**
* Add a directory to a Jar
*
@@ -403,9 +461,11 @@ public class BuildHelper {
private void addToJar(JarOutputStream jos, File dir, String prefix)
throws IOException {
File[] files = dir.listFiles();
+
addFilesToJar(jos, dir, files, prefix);
}
+
/**
* Add a set of files to a jar
*
@@ -420,11 +480,13 @@ public class BuildHelper {
File[] files, String prefix) throws IOException {
for (int i = 0; i < files.length; i++) {
String name = files[i].getPath().replace('\\', '/');
+
name = name.substring(dir.getPath().length() + 1);
if (prefix != null) {
name = prefix + "/" + name;
}
ZipEntry ze = new ZipEntry(name);
+
jos.putNextEntry(ze);
if (files[i].isDirectory()) {
addToJar(jos, files[i], name);
@@ -432,6 +494,7 @@ public class BuildHelper {
FileInputStream fis = new FileInputStream(files[i]);
int count = 0;
byte[] buf = new byte[8 * 1024];
+
count = fis.read(buf, 0, buf.length);
while (count != -1) {
jos.write(buf, 0, count);
@@ -442,9 +505,10 @@ public class BuildHelper {
}
}
+
/**
- * Build a simple fileset. Only simple inclusion filtering is supported
- * - no complicated patterns.
+ * Build a simple fileset. Only simple inclusion filtering is supported -
+ * no complicated patterns.
*
* @param filesetDir the base directory of the fileset
* @param filesetIncludes the simple includes spec for the fileset
@@ -455,11 +519,13 @@ public class BuildHelper {
return new File[0];
}
final String includes = resolve(filesetIncludes);
+
if (includes.indexOf("**") != -1) {
throw new RuntimeException("Simple fileset cannot handle ** "
+ "style includes");
}
int index = 0;
+
if (includes.charAt(0) == '*') {
index = 1;
}
@@ -469,6 +535,7 @@ public class BuildHelper {
}
File base = new File(resolve(filesetDir));
+
return base.listFiles(
new FilenameFilter() {
public boolean accept(File dir, String name) {
@@ -481,6 +548,7 @@ public class BuildHelper {
});
}
+
/**
* Resolve the property references in a string
*
@@ -490,11 +558,13 @@ public class BuildHelper {
*/
private String resolve(String propertyValue) {
String newValue = propertyValue;
+
while (newValue.indexOf("${") != -1) {
int index = newValue.indexOf("${");
int endIndex = newValue.indexOf("}", index);
String propertyName = newValue.substring(index + 2, endIndex);
String repValue = (String) properties.get(propertyName);
+
newValue = newValue.substring(0, index) +
repValue + newValue.substring(endIndex + 1);
}
diff --git a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Builder.java b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Builder.java
index 5b0fe3820..71e4ed69a 100644
--- a/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Builder.java
+++ b/proposal/mutant/src/java/bootstrap/org/apache/ant/builder/Builder.java
@@ -141,6 +141,7 @@ public class Builder {
addJavaFiles(files, UTIL_ROOT);
addJavaFiles(files, new File(UTIL_ROOT, "depend"));
addJavaFiles(files, ZIP_ROOT);
+ addJavaFiles(files, new File(UTIL_ROOT, "facade"));
files.add(new File(PACKAGE_ROOT, "BuildException.java"));
files.add(new File(PACKAGE_ROOT, "Location.java"));
@@ -163,7 +164,7 @@ public class Builder {
files.add(new File(UTIL_ROOT, "regexp/RegexpMatcherFactory.java"));
files.add(new File(FILTERS_ROOT, "util/ChainReaderHelper.java"));
- // these shouyld not be included
+ // these should not be included
files.remove(new File(TYPES_ROOT, "DataType.java"));
files.remove(new File(TASKDEFS_ROOT, "Ant.java"));
files.remove(new File(TASKDEFS_ROOT, "CallTarget.java"));
@@ -200,7 +201,7 @@ public class Builder {
mutantBuilder.common(mainBuild);
mutantBuilder.antcore(mainBuild);
mutantBuilder.start(mainBuild);
- mutantBuilder.cli(mainBuild);
+ mutantBuilder.frontend(mainBuild);
BuildHelper systemBuild = new BuildHelper();
systemBuild.setProperty("libset", "system");
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 8d79b61a0..e8a710da4 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
@@ -18,9 +18,9 @@ public class MutantBuilder {
helper.addPathElementToPath("classpath.antcore", "${distlib.dir}/common/common.jar");
helper.addPathToPath("classpath.antcore", "classpath.common");
helper.addPathToPath("classpath.antcore", "classpath.parser");
- helper.createPath("classpath.cli");
- helper.addPathElementToPath("classpath.cli", "${distlib.dir}/antcore/antcore.jar");
- helper.addPathToPath("classpath.cli", "classpath.antcore");
+ helper.createPath("classpath.frontend");
+ helper.addPathElementToPath("classpath.frontend", "${distlib.dir}/antcore/antcore.jar");
+ helper.addPathToPath("classpath.frontend", "classpath.antcore");
helper.createPath("classpath.start");
helper.addPathElementToPath("classpath.start", "${distlib.dir}/init.jar");
}
@@ -33,36 +33,38 @@ public class MutantBuilder {
helper.mkdir("${bin.dir}/init");
helper.javac("${java.dir}/init", "${bin.dir}/init", null);
helper.jar("${bin.dir}/init", "${distlib.dir}/init.jar",
- null, null);
+ null, null, null, null);
}
protected void common(BuildHelper helper) {
helper.mkdir("${bin.dir}/common");
helper.mkdir("${distlib.dir}/common");
helper.javac("${java.dir}/common", "${bin.dir}/common", "classpath.common");
helper.jar("${bin.dir}/common", "${distlib.dir}/common/common.jar",
- null, null);
+ null, null, null, null);
}
protected void antcore(BuildHelper helper) {
helper.mkdir("${bin.dir}/antcore");
helper.mkdir("${distlib.dir}/antcore");
helper.javac("${java.dir}/antcore", "${bin.dir}/antcore", "classpath.antcore");
helper.jar("${bin.dir}/antcore", "${distlib.dir}/antcore/antcore.jar",
- null, null);
+ null, null, null, null);
}
- protected void cli(BuildHelper helper) {
- helper.mkdir("${bin.dir}/cli");
+ protected void frontend(BuildHelper helper) {
+ helper.mkdir("${bin.dir}/frontend");
helper.mkdir("${distlib.dir}/frontend");
- helper.javac("${java.dir}/cli", "${bin.dir}/cli", "classpath.cli");
- helper.jar("${bin.dir}/cli", "${distlib.dir}/frontend/cli.jar",
- null, null);
+ helper.javac("${java.dir}/frontend", "${bin.dir}/frontend", "classpath.frontend");
+ helper.jar("${bin.dir}/frontend", "${distlib.dir}/frontend/frontend.jar",
+ null, null, null, null);
+ helper.jar("${bin.dir}/frontend", "${distlib.dir}/frontend/cli.jar",
+ null, null, "frontend.jar", "org.apache.ant.cli.Commandline");
}
protected void start(BuildHelper helper) {
helper.mkdir("${bin.dir}/start");
helper.javac("${java.dir}/start", "${bin.dir}/start", "classpath.start");
helper.jar("${bin.dir}/start", "${distlib.dir}/start.jar",
- null, null);
+ null, null, "init.jar", "org.apache.ant.start.Main");
helper.jar("${bin.dir}/start", "${distlib.dir}/ant.jar",
- null, null);
+ null, null, "start.jar", "org.apache.tools.ant.Main");
}
protected void ant1compat(BuildHelper helper) {
}
@@ -70,7 +72,7 @@ public class MutantBuilder {
helper.mkdir("${bin.dir}/remote");
helper.javac("${java.dir}/remote", "${bin.dir}/remote", "classpath.start");
helper.jar("${bin.dir}/remote", "${distlib.dir}/remote.jar",
- null, null);
+ null, null, null, "org.apache.ant.remote.RemoteMain");
}
protected void clean(BuildHelper helper) {
}
@@ -84,7 +86,7 @@ public class MutantBuilder {
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}.jar",
- "${java.dir}/antlibs/${libset}", "antlib.xml");
+ "${java.dir}/antlibs/${libset}", "antlib.xml", null, null);
}
protected void main(BuildHelper helper) {
}
diff --git a/proposal/mutant/src/java/cli/org/apache/ant/cli/BuildLogger.java b/proposal/mutant/src/java/frontend/org/apache/ant/cli/BuildLogger.java
similarity index 100%
rename from proposal/mutant/src/java/cli/org/apache/ant/cli/BuildLogger.java
rename to proposal/mutant/src/java/frontend/org/apache/ant/cli/BuildLogger.java
diff --git a/proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java b/proposal/mutant/src/java/frontend/org/apache/ant/cli/Commandline.java
similarity index 86%
rename from proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java
rename to proposal/mutant/src/java/frontend/org/apache/ant/cli/Commandline.java
index ef5306bc6..dd5c1a7d1 100755
--- a/proposal/mutant/src/java/cli/org/apache/ant/cli/Commandline.java
+++ b/proposal/mutant/src/java/frontend/org/apache/ant/cli/Commandline.java
@@ -79,6 +79,7 @@ import org.apache.ant.common.util.ConfigException;
import org.apache.ant.common.util.DemuxOutputStream;
import org.apache.ant.init.InitConfig;
import org.apache.ant.init.InitUtils;
+import org.apache.ant.frontend.FrontendUtils;
/**
* This is the command line front end. It drives the core.
@@ -87,12 +88,6 @@ import org.apache.ant.init.InitUtils;
* @created 9 January 2002
*/
public class Commandline {
- /** The default build file name */
- public static final String DEFAULT_BUILD_FILENAME = "build.ant";
-
- /** The default build file name */
- public static final String DEFAULT_ANT1_FILENAME = "build.xml";
-
/** The initialisation configuration for Ant */
private InitConfig initConfig;
@@ -182,58 +177,6 @@ public class Commandline {
}
}
- /**
- * Get the AntConfig from the given config area if it is available
- *
- * @param configArea the config area from which the config may be read
- * @return the AntConfig instance representing the config info read in
- * from the config area. May be null if the AntConfig is not
- * present
- * @exception ConfigException if the URL for the config file cannotbe
- * formed.
- */
- private AntConfig getAntConfig(File configArea) throws ConfigException {
- File configFile = new File(configArea, "antconfig.xml");
- try {
- return getAntConfigFile(configFile);
- } catch (FileNotFoundException e) {
- // ignore if files are not present
- return null;
- }
- }
-
- /**
- * Read in a config file
- *
- * @param configFile the file containing the XML config
- * @return the parsed config object
- * @exception ConfigException if the config cannot be parsed
- * @exception FileNotFoundException if the file cannot be found.
- */
- private AntConfig getAntConfigFile(File configFile)
- throws ConfigException, FileNotFoundException {
- try {
- URL configFileURL = InitUtils.getFileURL(configFile);
-
- ParseContext context = new ParseContext();
- AntConfigHandler configHandler = new AntConfigHandler();
-
- context.parse(configFileURL, "antconfig", configHandler);
-
- return configHandler.getAntConfig();
- } catch (MalformedURLException e) {
- throw new ConfigException("Unable to form URL to read config from "
- + configFile, e);
- } catch (XMLParseException e) {
- if (e.getCause() instanceof FileNotFoundException) {
- throw (FileNotFoundException) e.getCause();
- }
-
- throw new ConfigException("Unable to parse config file from "
- + configFile, e);
- }
- }
-
/**
* Get an option value
*
@@ -273,9 +216,10 @@ public class Commandline {
determineBuildFile();
AntConfig config = new AntConfig();
- AntConfig userConfig = getAntConfig(initConfig.getUserConfigArea());
+ AntConfig userConfig =
+ FrontendUtils.getAntConfig(initConfig.getUserConfigArea());
AntConfig systemConfig
- = getAntConfig(initConfig.getSystemConfigArea());
+ = FrontendUtils.getAntConfig(initConfig.getSystemConfigArea());
if (systemConfig != null) {
config.merge(systemConfig);
@@ -286,7 +230,8 @@ public class Commandline {
for (Iterator i = configFiles.iterator(); i.hasNext();) {
File configFile = (File) i.next();
- AntConfig runConfig = getAntConfigFile(configFile);
+ AntConfig runConfig
+ = FrontendUtils.getAntConfigFile(configFile);
config.merge(runConfig);
}
@@ -398,9 +343,11 @@ public class Commandline {
*/
private void determineBuildFile() throws ConfigException {
if (buildFileURL == null) {
- File defaultBuildFile = new File(DEFAULT_BUILD_FILENAME);
+ File defaultBuildFile
+ = new File(FrontendUtils.DEFAULT_BUILD_FILENAME);
if (!defaultBuildFile.exists()) {
- File ant1BuildFile = new File(DEFAULT_ANT1_FILENAME);
+ File ant1BuildFile
+ = new File(FrontendUtils.DEFAULT_ANT1_FILENAME);
if (ant1BuildFile.exists()) {
defaultBuildFile = ant1BuildFile;
}
diff --git a/proposal/mutant/src/java/cli/org/apache/ant/cli/DefaultLogger.java b/proposal/mutant/src/java/frontend/org/apache/ant/cli/DefaultLogger.java
similarity index 100%
rename from proposal/mutant/src/java/cli/org/apache/ant/cli/DefaultLogger.java
rename to proposal/mutant/src/java/frontend/org/apache/ant/cli/DefaultLogger.java
diff --git a/proposal/mutant/src/java/frontend/org/apache/ant/frontend/FrontendUtils.java b/proposal/mutant/src/java/frontend/org/apache/ant/frontend/FrontendUtils.java
new file mode 100644
index 000000000..004eefb83
--- /dev/null
+++ b/proposal/mutant/src/java/frontend/org/apache/ant/frontend/FrontendUtils.java
@@ -0,0 +1,136 @@
+/*
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 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 apache@apache.org.
+ *
+ * 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
+ * .
+ */
+package org.apache.ant.frontend;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.apache.ant.antcore.config.AntConfig;
+import org.apache.ant.antcore.config.AntConfigHandler;
+import org.apache.ant.antcore.xml.ParseContext;
+import org.apache.ant.antcore.xml.XMLParseException;
+import org.apache.ant.common.util.ConfigException;
+import org.apache.ant.init.InitUtils;
+
+/**
+ * Frontend Utilities methods and constants.
+ *
+ * @author Conor MacNeill
+ * @created 16 April 2002
+ */
+public class FrontendUtils {
+ /** The default build file name */
+ public static final String DEFAULT_BUILD_FILENAME = "build.ant";
+
+ /** The default build file name */
+ public static final String DEFAULT_ANT1_FILENAME = "build.xml";
+
+
+ /**
+ * Get the AntConfig from the given config area if it is available
+ *
+ * @param configArea the config area from which the config may be read
+ * @return the AntConfig instance representing the config info read in
+ * from the config area. May be null if the AntConfig is not present
+ * @exception ConfigException if the URL for the config file cannotbe
+ * formed.
+ */
+ public static AntConfig getAntConfig(File configArea)
+ throws ConfigException {
+ File configFile = new File(configArea, "antconfig.xml");
+
+ try {
+ return getAntConfigFile(configFile);
+ } catch (FileNotFoundException e) {
+ // ignore if files are not present
+ return null;
+ }
+ }
+
+
+ /**
+ * Read in a config file
+ *
+ * @param configFile the file containing the XML config
+ * @return the parsed config object
+ * @exception ConfigException if the config cannot be parsed
+ * @exception FileNotFoundException if the file cannot be found.
+ */
+ public static AntConfig getAntConfigFile(File configFile)
+ throws ConfigException, FileNotFoundException {
+ try {
+ URL configFileURL = InitUtils.getFileURL(configFile);
+
+ ParseContext context = new ParseContext();
+ AntConfigHandler configHandler = new AntConfigHandler();
+
+ context.parse(configFileURL, "antconfig", configHandler);
+
+ return configHandler.getAntConfig();
+ } catch (MalformedURLException e) {
+ throw new ConfigException("Unable to form URL to read config from "
+ + configFile, e);
+ } catch (XMLParseException e) {
+ if (e.getCause() instanceof FileNotFoundException) {
+ throw (FileNotFoundException) e.getCause();
+ }
+
+ throw new ConfigException("Unable to parse config file from "
+ + configFile, e);
+ }
+ }
+
+}
+