--- build.sh.orig 2006-02-22 00:24:13.000000000 +0100 +++ build.sh 2006-02-22 00:26:46.000000000 +0100 @@ -41,5 +41,5 @@ ANT_INSTALL="-emacs" fi -bootstrap/bin/ant -lib lib/optional "$ANT_INSTALL" $* +bootstrap/bin/ant -lib lib/optional -Dbuild.compiler=ecj "$ANT_INSTALL" $* --- bootstrap.sh.orig 2006-02-22 17:06:18.000000000 +0100 +++ bootstrap.sh 2006-02-22 17:05:45.000000000 +0100 @@ -126,7 +126,7 @@ echo ... Compiling Ant Classes -"${JAVAC}" $BOOTJAVAC_OPTS -d ${CLASSDIR} ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \ +${JAVAC} $BOOTJAVAC_OPTS -d ${CLASSDIR} ${TOOLS}/bzip2/*.java ${TOOLS}/tar/*.java ${TOOLS}/zip/*.java \ ${TOOLS}/ant/util/regexp/RegexpMatcher.java \ ${TOOLS}/ant/util/regexp/RegexpMatcherFactory.java \ ${TOOLS}/ant/types/*.java \ @@ -150,7 +150,7 @@ echo ... Building Ant Distribution -"${JAVACMD}" -classpath "${CLASSPATH}" -Dant.home=. $ANT_OPTS org.apache.tools.ant.Main -emacs "$@" bootstrap +"${JAVACMD}" -classpath "${CLASSPATH}" -Dbuild.compiler=ecj -Dant.home=. $ANT_OPTS org.apache.tools.ant.Main -emacs "$@" bootstrap ret=$? if [ $ret != 0 ]; then echo ... Failed Building Ant Distribution ! --- src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java.orig 2006-02-22 16:43:17.000000000 +0100 +++ src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java 2006-02-22 16:43:41.000000000 +0100 @@ -120,6 +120,9 @@ if (compilerType.equalsIgnoreCase("kjc")) { return new Kjc(); } + if (compilerType.equalsIgnoreCase("ecj")) { + return new Ecj(); + } if (compilerType.equalsIgnoreCase("gcj")) { return new Gcj(); } --- /dev/null 2005-12-16 14:04:54.000000000 +0100 +++ src/main/org/apache/tools/ant/taskdefs/compilers/Ecj.java 2006-02-22 16:45:18.000000000 +0100 @@ -0,0 +1,99 @@ +/* + * Copyright 2001-2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.compilers; + + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; + +/** + * The implementation of the ecj compiler. + * This is primarily a cut-and-paste from the jikes. + * + * @since Ant 1.4 + */ +public class Ecj extends DefaultCompilerAdapter { + + /** + * Performs a compile using the ecj compiler. + */ + public boolean execute() throws BuildException { + Commandline cmd; + attributes.log("Using ecj compiler", Project.MSG_VERBOSE); + cmd = setupECJCommand(); + + int firstFileName = cmd.size(); + logAndAddFilesToCompile(cmd); + + return + executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; + } + + protected Commandline setupECJCommand() { + Commandline cmd = new Commandline(); + Path classpath = new Path(project); + + // ecj doesn't support bootclasspath dir (-bootclasspath) + // so we'll emulate it for compatibility and convenience. + if (bootclasspath != null) { + classpath.append(bootclasspath); + } + + // ecj doesn't support an extension dir (-extdir) + // so we'll emulate it for compatibility and convenience. + classpath.addExtdirs(extdirs); + + classpath.append(getCompileClasspath()); + + // Gcj has no option for source-path so we + // will add it to classpath. + if (compileSourcepath != null) { + classpath.append(compileSourcepath); + } else { + classpath.append(src); + } + + cmd.setExecutable("ecj"); + + if (destDir != null) { + cmd.createArgument().setValue("-d"); + cmd.createArgument().setFile(destDir); + + if (!destDir.exists() && !destDir.mkdirs()) { + throw new BuildException("Can't make output directories. " + + "Maybe permission is wrong. "); + } + } + + cmd.createArgument().setValue("-classpath"); + cmd.createArgument().setPath(classpath); + + if (encoding != null) { + cmd.createArgument().setValue("-encoding " + encoding); + } + if (debug) { + cmd.createArgument().setValue("-g"); + } + + addCurrentCompilerArgs(cmd); + + return cmd; + } +}