diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers')
14 files changed, 0 insertions, 2218 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java deleted file mode 100644 index 9503ac02..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 java.io.File; -import java.lang.reflect.Method; -import java.util.Enumeration; -import java.util.Vector; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Apt; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; - - -/** - * <p>The implementation of the apt compiler for JDK 1.5.</p> - * - * <p>As usual, the low level entry points for Java tools are neither documented or - * stable; this entry point may change from that of 1.5.0_01-b08 without any - * warning at all. The IDE decompile of the tool entry points is as follows:</p> - * <pre> - * public class Main { - * public Main() ; - * - * public static transient void main(String... strings); - * - * public static transient int process(String... strings); - * - * public static transient int process(PrintWriter printWriter, - * String... strings); - * public static transient int process( - * AnnotationProcessorFactory annotationProcessorFactory, - * String... strings); - * - * public static transient int process( - * AnnotationProcessorFactory annotationProcessorFactory, - * PrintWriter printWriter, - * String... strings); - * private static transient int processing( - * AnnotationProcessorFactory annotationProcessorFactory, - * PrintWriter printWriter, - * String... strings) ; - * } - * </pre> - * - * This Adapter is designed to run Apt in-JVM, an option that is not actually - * exposed to end-users, because it was too brittle during beta testing; classpath - * problems being the core issue. - * - * @since Ant 1.7 - */ -public class AptCompilerAdapter extends DefaultCompilerAdapter { - - /** - * Integer returned by the Apt compiler to indicate success. - */ - private static final int APT_COMPILER_SUCCESS = 0; - /** - * class in tools.jar that implements APT - */ - public static final String APT_ENTRY_POINT = "com.sun.tools.apt.Main"; - - /** - * method used to compile. - */ - public static final String APT_METHOD_NAME = "process"; - - /** - * Get the facade task that fronts this adapter - * - * @return task instance - * @see DefaultCompilerAdapter#getJavac() - */ - protected Apt getApt() { - return (Apt) getJavac(); - } - - /** - * Using the front end arguments, set up the command line to run Apt - * - * @param apt task - * @param cmd command that is set up with the various switches from the task - * options - */ - static void setAptCommandlineSwitches(final Apt apt, final Commandline cmd) { - - if (!apt.isCompile()) { - cmd.createArgument().setValue("-nocompile"); - } - - // Process the factory class - final String factory = apt.getFactory(); - if (factory != null) { - cmd.createArgument().setValue("-factory"); - cmd.createArgument().setValue(factory); - } - - // Process the factory path - final Path factoryPath = apt.getFactoryPath(); - if (factoryPath != null) { - cmd.createArgument().setValue("-factorypath"); - cmd.createArgument().setPath(factoryPath); - } - - final File preprocessDir = apt.getPreprocessDir(); - if (preprocessDir != null) { - cmd.createArgument().setValue("-s"); - cmd.createArgument().setFile(preprocessDir); - } - - // Process the processor options - final Vector options = apt.getOptions(); - final Enumeration elements = options.elements(); - Apt.Option opt; - StringBuffer arg = null; - while (elements.hasMoreElements()) { - opt = (Apt.Option) elements.nextElement(); - arg = new StringBuffer(); - arg.append("-A").append(opt.getName()); - if (opt.getValue() != null) { - arg.append("=").append(opt.getValue()); - } - cmd.createArgument().setValue(arg.toString()); - } - } - - /** - * using our front end task, set up the command line switches - * - * @param cmd command line to set up - */ - protected void setAptCommandlineSwitches(final Commandline cmd) { - final Apt apt = getApt(); - setAptCommandlineSwitches(apt, cmd); - } - - /** - * Run the compilation. - * @return true on success. - * @throws BuildException if the compilation has problems. - */ - public boolean execute() throws BuildException { - attributes.log("Using apt compiler", Project.MSG_VERBOSE); - //set up the javac options - final Commandline cmd = setupModernJavacCommand(); - //then add the Apt options - setAptCommandlineSwitches(cmd); - - //finally invoke APT - // Use reflection to be able to build on all JDKs: - try { - final Class c = Class.forName(APT_ENTRY_POINT); - final Object compiler = c.newInstance(); - final Method compile = c.getMethod(APT_METHOD_NAME, - new Class[]{(new String[]{}).getClass()}); - final int result = ((Integer) compile.invoke - (compiler, new Object[]{cmd.getArguments()})) - .intValue(); - return (result == APT_COMPILER_SUCCESS); - } catch (final BuildException be) { - //rethrow build exceptions - throw be; - } catch (final Exception ex) { - //cast everything else to a build exception - throw new BuildException("Error starting apt compiler", - ex, location); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java deleted file mode 100644 index dadb55ba..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/AptExternalCompilerAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.taskdefs.Apt; -import org.apache.tools.ant.types.Commandline; - -/** - * The implementation of the apt compiler for JDK 1.5 using an external process - * - * @since Ant 1.7 - */ -public class AptExternalCompilerAdapter extends DefaultCompilerAdapter { - - - /** - * Get the facade task that fronts this adapter - * - * @return task instance - * @see DefaultCompilerAdapter#getJavac() - */ - protected Apt getApt() { - return (Apt) getJavac(); - } - - /** - * Performs a compile using the Javac externally. - * @return true the compilation was successful. - * @throws BuildException if there is a problem. - */ - public boolean execute() throws BuildException { - attributes.log("Using external apt compiler", Project.MSG_VERBOSE); - - - // Setup the apt executable - Apt apt = getApt(); - Commandline cmd = new Commandline(); - cmd.setExecutable(apt.getAptExecutable()); - setupModernJavacCommandlineSwitches(cmd); - AptCompilerAdapter.setAptCommandlineSwitches(apt, cmd); - int firstFileName = cmd.size(); - //add the files - logAndAddFilesToCompile(cmd); - - //run - return 0 == executeExternalCompile(cmd.getCommandline(), - firstFileName, - true); - - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java deleted file mode 100644 index 5a275b8c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.taskdefs.Javac; - -/** - * The interface that all compiler adapters must adhere to. - * - * <p>A compiler adapter is an adapter that interprets the javac's - * parameters in preparation to be passed off to the compiler this - * adapter represents. As all the necessary values are stored in the - * Javac task itself, the only thing all adapters need is the javac - * task, the execute command and a parameterless constructor (for - * reflection).</p> - * - * @since Ant 1.3 - */ - -public interface CompilerAdapter { - - /** - * Sets the compiler attributes, which are stored in the Javac task. - * @param attributes the compiler attributes - */ - void setJavac(Javac attributes); - - /** - * Executes the task. - * - * @return has the compilation been successful - * @throws BuildException on error - */ - boolean execute() throws BuildException; -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterExtension.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterExtension.java deleted file mode 100644 index 038b9cbe..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterExtension.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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; - -/** - * Extension interface for compilers that support source extensions - * other than .java. - * - * @since Ant 1.8.2 - */ -public interface CompilerAdapterExtension { - - /** - * Returns a list of source file extensions that are recognized by - * this compiler adapter. - * - * <p>For example, most compiler adapters will return [ "java" ], - * but a compiler adapter that can compile both Java and Groovy - * source code would return [ "java", "groovy" ].</p> - * - * @return list of source file extensions recognized by this - * compiler adapter. - */ - String[] getSupportedFileExtensions(); -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java deleted file mode 100644 index aeecb4a5..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/CompilerAdapterFactory.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.Task; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.ClasspathUtils; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * Creates the necessary compiler adapter, given basic criteria. - * - * @since Ant 1.3 - */ -public final class CompilerAdapterFactory { - private static final String MODERN_COMPILER = "com.sun.tools.javac.Main"; - - /** This is a singleton -- can't create instances!! */ - private CompilerAdapterFactory() { - } - - /** - * Based on the parameter passed in, this method creates the necessary - * factory desired. - * - * The current mapping for compiler names are as follows: - * <ul><li>jikes = jikes compiler - * <li>classic, javac1.1, javac1.2 = the standard compiler from JDK - * 1.1/1.2 - * <li>modern, javac1.3, javac1.4, javac1.5 = the compiler of JDK 1.3+ - * <li>jvc, microsoft = the command line compiler from Microsoft's SDK - * for Java / Visual J++ - * <li>kjc = the kopi compiler</li> - * <li>gcj = the gcj compiler from gcc</li> - * <li>sj, symantec = the Symantec Java compiler</li> - * <li><i>a fully qualified classname</i> = the name of a compiler - * adapter - * </ul> - * - * @param compilerType either the name of the desired compiler, or the - * full classname of the compiler's adapter. - * @param task a task to log through. - * @return the compiler adapter - * @throws BuildException if the compiler type could not be resolved into - * a compiler adapter. - */ - public static CompilerAdapter getCompiler(String compilerType, Task task) - throws BuildException { - return getCompiler(compilerType, task, null); - } - - /** - * Based on the parameter passed in, this method creates the necessary - * factory desired. - * - * The current mapping for compiler names are as follows: - * <ul><li>jikes = jikes compiler - * <li>classic, javac1.1, javac1.2 = the standard compiler from JDK - * 1.1/1.2 - * <li>modern, javac1.3, javac1.4, javac1.5 = the compiler of JDK 1.3+ - * <li>jvc, microsoft = the command line compiler from Microsoft's SDK - * for Java / Visual J++ - * <li>kjc = the kopi compiler</li> - * <li>gcj = the gcj compiler from gcc</li> - * <li>sj, symantec = the Symantec Java compiler</li> - * <li><i>a fully qualified classname</i> = the name of a compiler - * adapter - * </ul> - * - * @param compilerType either the name of the desired compiler, or the - * full classname of the compiler's adapter. - * @param task a task to log through. - * @param classpath the classpath to use when looking up an - * adapter class - * @return the compiler adapter - * @throws BuildException if the compiler type could not be resolved into - * a compiler adapter. - * @since Ant 1.8.0 - */ - public static CompilerAdapter getCompiler(String compilerType, Task task, - Path classpath) - throws BuildException { - if (compilerType.equalsIgnoreCase("jikes")) { - return new Jikes(); - } - if (compilerType.equalsIgnoreCase("extjavac")) { - return new JavacExternal(); - } - if (compilerType.equalsIgnoreCase("classic") - || compilerType.equalsIgnoreCase("javac1.1") - || compilerType.equalsIgnoreCase("javac1.2")) { - task.log("This version of java does " - + "not support the classic " - + "compiler; upgrading to modern", - Project.MSG_WARN); - compilerType = "modern"; - } - //on java<=1.3 the modern falls back to classic if it is not found - //but on java>=1.4 we just bail out early - if (compilerType.equalsIgnoreCase("modern") - || compilerType.equalsIgnoreCase("javac1.3") - || compilerType.equalsIgnoreCase("javac1.4") - || compilerType.equalsIgnoreCase("javac1.5") - || compilerType.equalsIgnoreCase("javac1.6") - || compilerType.equalsIgnoreCase("javac1.7") - || compilerType.equalsIgnoreCase("javac1.8") - || compilerType.equalsIgnoreCase("javac1.9")) { - // does the modern compiler exist? - if (doesModernCompilerExist()) { - return new Javac13(); - } else { - throw new BuildException("Unable to find a javac " - + "compiler;\n" - + MODERN_COMPILER - + " is not on the " - + "classpath.\n" - + "Perhaps JAVA_HOME does not" - + " point to the JDK.\n" - + "It is currently set to \"" - + JavaEnvUtils.getJavaHome() - + "\""); - } - } - - if (compilerType.equalsIgnoreCase("jvc") - || compilerType.equalsIgnoreCase("microsoft")) { - return new Jvc(); - } - if (compilerType.equalsIgnoreCase("kjc")) { - return new Kjc(); - } - if (compilerType.equalsIgnoreCase("gcj")) { - return new Gcj(); - } - if (compilerType.equalsIgnoreCase("sj") - || compilerType.equalsIgnoreCase("symantec")) { - return new Sj(); - } - return resolveClassName(compilerType, - // Memory-Leak in line below - task.getProject().createClassLoader(classpath)); - } - - /** - * query for the Modern compiler existing - * @return true if classic os on the classpath - */ - private static boolean doesModernCompilerExist() { - try { - Class.forName(MODERN_COMPILER); - return true; - } catch (ClassNotFoundException cnfe) { - try { - ClassLoader cl = CompilerAdapterFactory.class.getClassLoader(); - if (cl != null) { - cl.loadClass(MODERN_COMPILER); - return true; - } - } catch (ClassNotFoundException cnfe2) { - // Ignore Exception - } - } - return false; - } - - /** - * Tries to resolve the given classname into a compiler adapter. - * Throws a fit if it can't. - * - * @param className The fully qualified classname to be created. - * @param loader the classloader to use - * @throws BuildException This is the fit that is thrown if className - * isn't an instance of CompilerAdapter. - */ - private static CompilerAdapter resolveClassName(String className, - ClassLoader loader) - throws BuildException { - return (CompilerAdapter) ClasspathUtils.newInstance(className, - loader != null ? loader : - CompilerAdapterFactory.class.getClassLoader(), - CompilerAdapter.class); - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java deleted file mode 100644 index 519163cc..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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; - -//Java5 style -//import static org.apache.tools.ant.util.StringUtils.LINE_SEP; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Location; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Execute; -import org.apache.tools.ant.taskdefs.Javac; -import org.apache.tools.ant.taskdefs.LogStreamHandler; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.JavaEnvUtils; -import org.apache.tools.ant.util.StringUtils; - -/** - * This is the default implementation for the CompilerAdapter interface. - * Currently, this is a cut-and-paste of the original javac task. - * - * @since Ant 1.3 - */ -public abstract class DefaultCompilerAdapter - implements CompilerAdapter, CompilerAdapterExtension { - - private static final int COMMAND_LINE_LIMIT; - static { - if (Os.isFamily("os/2")) { - // OS/2 CMD.EXE has a much smaller limit around 1K - COMMAND_LINE_LIMIT = 1000; - } else { - COMMAND_LINE_LIMIT = 4096; // 4K - } - } - // CheckStyle:VisibilityModifier OFF - bc - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - protected Path src; - protected File destDir; - protected String encoding; - protected boolean debug = false; - protected boolean optimize = false; - protected boolean deprecation = false; - protected boolean depend = false; - protected boolean verbose = false; - protected String target; - protected Path bootclasspath; - protected Path extdirs; - protected Path compileClasspath; - protected Path compileSourcepath; - protected Project project; - protected Location location; - protected boolean includeAntRuntime; - protected boolean includeJavaRuntime; - protected String memoryInitialSize; - protected String memoryMaximumSize; - - protected File[] compileList; - protected Javac attributes; - - //must keep for subclass BC, though unused: - // CheckStyle:ConstantNameCheck OFF - bc - protected static final String lSep = StringUtils.LINE_SEP; - - // CheckStyle:ConstantNameCheck ON - // CheckStyle:VisibilityModifier ON - - /** - * Set the Javac instance which contains the configured compilation - * attributes. - * - * @param attributes a configured Javac task. - */ - public void setJavac(final Javac attributes) { - this.attributes = attributes; - src = attributes.getSrcdir(); - destDir = attributes.getDestdir(); - encoding = attributes.getEncoding(); - debug = attributes.getDebug(); - optimize = attributes.getOptimize(); - deprecation = attributes.getDeprecation(); - depend = attributes.getDepend(); - verbose = attributes.getVerbose(); - target = attributes.getTarget(); - bootclasspath = attributes.getBootclasspath(); - extdirs = attributes.getExtdirs(); - compileList = attributes.getFileList(); - compileClasspath = attributes.getClasspath(); - compileSourcepath = attributes.getSourcepath(); - project = attributes.getProject(); - location = attributes.getLocation(); - includeAntRuntime = attributes.getIncludeantruntime(); - includeJavaRuntime = attributes.getIncludejavaruntime(); - memoryInitialSize = attributes.getMemoryInitialSize(); - memoryMaximumSize = attributes.getMemoryMaximumSize(); - } - - /** - * Get the Javac task instance associated with this compiler adapter - * - * @return the configured Javac task instance used by this adapter. - */ - public Javac getJavac() { - return attributes; - } - - /** - * By default, only recognize files with a Java extension, - * but specialized compilers can recognize multiple kinds - * of files. - */ - public String[] getSupportedFileExtensions() { - return new String[] {"java"}; - } - - /** - * Get the project this compiler adapter was created in. - * @return the owner project - * @since Ant 1.6 - */ - protected Project getProject() { - return project; - } - - /** - * Builds the compilation classpath. - * @return the compilation class path - */ - protected Path getCompileClasspath() { - final Path classpath = new Path(project); - - // add dest dir to classpath so that previously compiled and - // untouched classes are on classpath - - if (destDir != null && getJavac().isIncludeDestClasses()) { - classpath.setLocation(destDir); - } - - // Combine the build classpath with the system classpath, in an - // order determined by the value of build.sysclasspath - - Path cp = compileClasspath; - if (cp == null) { - cp = new Path(project); - } - if (includeAntRuntime) { - classpath.addExisting(cp.concatSystemClasspath("last")); - } else { - classpath.addExisting(cp.concatSystemClasspath("ignore")); - } - - if (includeJavaRuntime) { - classpath.addJavaRuntime(); - } - - return classpath; - } - - /** - * Get the command line arguments for the switches. - * @param cmd the command line - * @return the command line - */ - protected Commandline setupJavacCommandlineSwitches(final Commandline cmd) { - return setupJavacCommandlineSwitches(cmd, false); - } - - /** - * Does the command line argument processing common to classic and - * modern. Doesn't add the files to compile. - * @param cmd the command line - * @param useDebugLevel if true set set the debug level with the -g switch - * @return the command line - */ - protected Commandline setupJavacCommandlineSwitches(final Commandline cmd, - final boolean useDebugLevel) { - final Path classpath = getCompileClasspath(); - // For -sourcepath, use the "sourcepath" value if present. - // Otherwise default to the "srcdir" value. - Path sourcepath = null; - if (compileSourcepath != null) { - sourcepath = compileSourcepath; - } else { - sourcepath = src; - } - - final String memoryParameterPrefix = assumeJava11() ? "-J-" : "-J-X"; - if (memoryInitialSize != null) { - if (!attributes.isForkedJavac()) { - attributes.log("Since fork is false, ignoring " - + "memoryInitialSize setting.", - Project.MSG_WARN); - } else { - cmd.createArgument().setValue(memoryParameterPrefix - + "ms" + memoryInitialSize); - } - } - - if (memoryMaximumSize != null) { - if (!attributes.isForkedJavac()) { - attributes.log("Since fork is false, ignoring " - + "memoryMaximumSize setting.", - Project.MSG_WARN); - } else { - cmd.createArgument().setValue(memoryParameterPrefix - + "mx" + memoryMaximumSize); - } - } - - if (attributes.getNowarn()) { - cmd.createArgument().setValue("-nowarn"); - } - - if (deprecation) { - cmd.createArgument().setValue("-deprecation"); - } - - if (destDir != null) { - cmd.createArgument().setValue("-d"); - cmd.createArgument().setFile(destDir); - } - - cmd.createArgument().setValue("-classpath"); - - // Just add "sourcepath" to classpath ( for JDK1.1 ) - // as well as "bootclasspath" and "extdirs" - if (assumeJava11()) { - final Path cp = new Path(project); - - final Path bp = getBootClassPath(); - if (bp.size() > 0) { - cp.append(bp); - } - - if (extdirs != null) { - cp.addExtdirs(extdirs); - } - cp.append(classpath); - cp.append(sourcepath); - cmd.createArgument().setPath(cp); - } else { - cmd.createArgument().setPath(classpath); - // If the buildfile specifies sourcepath="", then don't - // output any sourcepath. - if (sourcepath.size() > 0) { - cmd.createArgument().setValue("-sourcepath"); - cmd.createArgument().setPath(sourcepath); - } - if (target != null) { - cmd.createArgument().setValue("-target"); - cmd.createArgument().setValue(target); - } - - final Path bp = getBootClassPath(); - if (bp.size() > 0) { - cmd.createArgument().setValue("-bootclasspath"); - cmd.createArgument().setPath(bp); - } - - if (extdirs != null && extdirs.size() > 0) { - cmd.createArgument().setValue("-extdirs"); - cmd.createArgument().setPath(extdirs); - } - } - - if (encoding != null) { - cmd.createArgument().setValue("-encoding"); - cmd.createArgument().setValue(encoding); - } - if (debug) { - if (useDebugLevel && !assumeJava11()) { - final String debugLevel = attributes.getDebugLevel(); - if (debugLevel != null) { - cmd.createArgument().setValue("-g:" + debugLevel); - } else { - cmd.createArgument().setValue("-g"); - } - } else { - cmd.createArgument().setValue("-g"); - } - } else if (getNoDebugArgument() != null) { - cmd.createArgument().setValue(getNoDebugArgument()); - } - if (optimize) { - cmd.createArgument().setValue("-O"); - } - - if (depend) { - if (assumeJava11()) { - cmd.createArgument().setValue("-depend"); - } else if (assumeJava12()) { - cmd.createArgument().setValue("-Xdepend"); - } else { - attributes.log("depend attribute is not supported by the " - + "modern compiler", Project.MSG_WARN); - } - } - - if (verbose) { - cmd.createArgument().setValue("-verbose"); - } - - addCurrentCompilerArgs(cmd); - - return cmd; - } - - /** - * Does the command line argument processing for modern. Doesn't - * add the files to compile. - * @param cmd the command line - * @return the command line - */ - protected Commandline setupModernJavacCommandlineSwitches(final Commandline cmd) { - setupJavacCommandlineSwitches(cmd, true); - if (!assumeJava13()) { // -source added with JDK 1.4 - final String t = attributes.getTarget(); - if (attributes.getSource() != null) { - cmd.createArgument().setValue("-source"); - cmd.createArgument() - .setValue(adjustSourceValue(attributes.getSource())); - - } else if (t != null && mustSetSourceForTarget(t)) { - setImplicitSourceSwitch(cmd, t, adjustSourceValue(t)); - } - } - return cmd; - } - - /** - * Does the command line argument processing for modern and adds - * the files to compile as well. - * @return the command line - */ - protected Commandline setupModernJavacCommand() { - final Commandline cmd = new Commandline(); - setupModernJavacCommandlineSwitches(cmd); - - logAndAddFilesToCompile(cmd); - return cmd; - } - - /** - * Set up the command line. - * @return the command line - */ - protected Commandline setupJavacCommand() { - return setupJavacCommand(false); - } - - /** - * Does the command line argument processing for classic and adds - * the files to compile as well. - * @param debugLevelCheck if true set the debug level with the -g switch - * @return the command line - */ - protected Commandline setupJavacCommand(final boolean debugLevelCheck) { - final Commandline cmd = new Commandline(); - setupJavacCommandlineSwitches(cmd, debugLevelCheck); - logAndAddFilesToCompile(cmd); - return cmd; - } - - /** - * Logs the compilation parameters, adds the files to compile and logs the - * "niceSourceList" - * @param cmd the command line - */ - protected void logAndAddFilesToCompile(final Commandline cmd) { - attributes.log("Compilation " + cmd.describeArguments(), - Project.MSG_VERBOSE); - - final StringBuffer niceSourceList = new StringBuffer("File"); - if (compileList.length != 1) { - niceSourceList.append("s"); - } - niceSourceList.append(" to be compiled:"); - - niceSourceList.append(StringUtils.LINE_SEP); - - for (int i = 0; i < compileList.length; i++) { - final String arg = compileList[i].getAbsolutePath(); - cmd.createArgument().setValue(arg); - niceSourceList.append(" "); - niceSourceList.append(arg); - niceSourceList.append(StringUtils.LINE_SEP); - } - - attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE); - } - - /** - * Do the compile with the specified arguments. - * @param args - arguments to pass to process on command line - * @param firstFileName - index of the first source file in args, - * if the index is negative, no temporary file will ever be - * created, but this may hit the command line length limit on your - * system. - * @return the exit code of the compilation - */ - protected int executeExternalCompile(final String[] args, final int firstFileName) { - return executeExternalCompile(args, firstFileName, true); - } - - /** - * Do the compile with the specified arguments. - * - * <p>The working directory if the executed process will be the - * project's base directory.</p> - * - * @param args - arguments to pass to process on command line - * @param firstFileName - index of the first source file in args, - * if the index is negative, no temporary file will ever be - * created, but this may hit the command line length limit on your - * system. - * @param quoteFiles - if set to true, filenames containing - * spaces will be quoted when they appear in the external file. - * This is necessary when running JDK 1.4's javac and probably - * others. - * @return the exit code of the compilation - * - * @since Ant 1.6 - */ - protected int executeExternalCompile(final String[] args, final int firstFileName, - final boolean quoteFiles) { - String[] commandArray = null; - File tmpFile = null; - - try { - /* - * Many system have been reported to get into trouble with - * long command lines - no, not only Windows ;-). - * - * POSIX seems to define a lower limit of 4k, so use a temporary - * file if the total length of the command line exceeds this limit. - */ - if (Commandline.toString(args).length() > COMMAND_LINE_LIMIT - && firstFileName >= 0) { - BufferedWriter out = null; - try { - tmpFile = FILE_UTILS.createTempFile( - "files", "", getJavac().getTempdir(), true, true); - out = new BufferedWriter(new FileWriter(tmpFile)); - for (int i = firstFileName; i < args.length; i++) { - if (quoteFiles && args[i].indexOf(" ") > -1) { - args[i] = args[i].replace(File.separatorChar, '/'); - out.write("\"" + args[i] + "\""); - } else { - out.write(args[i]); - } - out.newLine(); - } - out.flush(); - commandArray = new String[firstFileName + 1]; - System.arraycopy(args, 0, commandArray, 0, firstFileName); - commandArray[firstFileName] = "@" + tmpFile; - } catch (final IOException e) { - throw new BuildException("Error creating temporary file", - e, location); - } finally { - FileUtils.close(out); - } - } else { - commandArray = args; - } - - try { - final Execute exe = new Execute( - new LogStreamHandler(attributes, - Project.MSG_INFO, - Project.MSG_WARN)); - if (Os.isFamily("openvms")) { - //Use the VM launcher instead of shell launcher on VMS - //for java - exe.setVMLauncher(true); - } - exe.setAntRun(project); - exe.setWorkingDirectory(project.getBaseDir()); - exe.setCommandline(commandArray); - exe.execute(); - return exe.getExitValue(); - } catch (final IOException e) { - throw new BuildException("Error running " + args[0] - + " compiler", e, location); - } - } finally { - if (tmpFile != null) { - tmpFile.delete(); - } - } - } - - /** - * Add extdirs to classpath - * @param classpath the classpath to use - * @deprecated since 1.5.x. - * Use org.apache.tools.ant.types.Path#addExtdirs instead. - */ - @Deprecated - protected void addExtdirsToClasspath(final Path classpath) { - classpath.addExtdirs(extdirs); - } - - /** - * Adds the command line arguments specific to the current implementation. - * @param cmd the command line to use - */ - protected void addCurrentCompilerArgs(final Commandline cmd) { - cmd.addArguments(getJavac().getCurrentCompilerArgs()); - } - - /** - * Shall we assume JDK 1.1 command line switches? - * @return true if jdk 1.1 - * @since Ant 1.5 - */ - protected boolean assumeJava11() { - return "javac1.1".equals(attributes.getCompilerVersion()); - } - - /** - * Shall we assume JDK 1.2 command line switches? - * @return true if jdk 1.2 - * @since Ant 1.5 - */ - protected boolean assumeJava12() { - return "javac1.2".equals(attributes.getCompilerVersion()); - } - - /** - * Shall we assume JDK 1.3 command line switches? - * @return true if jdk 1.3 - * @since Ant 1.5 - */ - protected boolean assumeJava13() { - return "javac1.3".equals(attributes.getCompilerVersion()); - } - - /** - * Shall we assume JDK 1.4 command line switches? - * @return true if jdk 1.4 - * @since Ant 1.6.3 - */ - protected boolean assumeJava14() { - return assumeJavaXY("javac1.4", JavaEnvUtils.JAVA_1_4); - } - - /** - * Shall we assume JDK 1.5 command line switches? - * @return true if JDK 1.5 - * @since Ant 1.6.3 - */ - protected boolean assumeJava15() { - return assumeJavaXY("javac1.5", JavaEnvUtils.JAVA_1_5); - } - - /** - * Shall we assume JDK 1.6 command line switches? - * @return true if JDK 1.6 - * @since Ant 1.7 - */ - protected boolean assumeJava16() { - return assumeJavaXY("javac1.6", JavaEnvUtils.JAVA_1_6); - } - - /** - * Shall we assume JDK 1.7 command line switches? - * @return true if JDK 1.7 - * @since Ant 1.8.2 - */ - protected boolean assumeJava17() { - return assumeJavaXY("javac1.7", JavaEnvUtils.JAVA_1_7); - } - - /** - * Shall we assume JDK 1.8 command line switches? - * @return true if JDK 1.8 - * @since Ant 1.8.3 - */ - protected boolean assumeJava18() { - return assumeJavaXY("javac1.8", JavaEnvUtils.JAVA_1_8); - } - - /** - * Shall we assume JDK 1.9 command line switches? - * @return true if JDK 1.9 - * @since Ant 1.9.4 - */ - protected boolean assumeJava19() { - return assumeJavaXY("javac1.9", JavaEnvUtils.JAVA_1_9); - } - - /** - * Shall we assume command line switches for the given version of Java? - * @since Ant 1.8.3 - */ - private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) { - return javacXY.equals(attributes.getCompilerVersion()) - || ("classic".equals(attributes.getCompilerVersion()) - && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) - || ("modern".equals(attributes.getCompilerVersion()) - && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)) - || ("extJavac".equals(attributes.getCompilerVersion()) - && JavaEnvUtils.isJavaVersion(javaEnvVersionXY)); - } - - /** - * Combines a user specified bootclasspath with the system - * bootclasspath taking build.sysclasspath into account. - * - * @return a non-null Path instance that combines the user - * specified and the system bootclasspath. - */ - protected Path getBootClassPath() { - final Path bp = new Path(project); - if (bootclasspath != null) { - bp.append(bootclasspath); - } - return bp.concatSystemBootClasspath("ignore"); - } - - /** - * The argument the compiler wants to see if the debug attribute - * has been set to false. - * - * <p>A return value of <code>null</code> means no argument at all.</p> - * - * @return "-g:none" unless we expect to invoke a JDK 1.1 compiler. - * - * @since Ant 1.6.3 - */ - protected String getNoDebugArgument() { - return assumeJava11() ? null : "-g:none"; - } - - private void setImplicitSourceSwitch(final Commandline cmd, - final String target, final String source) { - attributes.log("", Project.MSG_WARN); - attributes.log(" WARNING", Project.MSG_WARN); - attributes.log("", Project.MSG_WARN); - attributes.log("The -source switch defaults to " + getDefaultSource() - + ".", - Project.MSG_WARN); - attributes.log("If you specify -target " + target - + " you now must also specify -source " + source - + ".", Project.MSG_WARN); - attributes.log("Ant will implicitly add -source " + source - + " for you. Please change your build file.", - Project.MSG_WARN); - cmd.createArgument().setValue("-source"); - cmd.createArgument().setValue(source); - } - - /** - * A string that describes the default value for -source of the - * selected JDK's javac. - */ - private String getDefaultSource() { - if (assumeJava15() || assumeJava16()) { - return "1.5 in JDK 1.5 and 1.6"; - } - if (assumeJava17()) { - return "1.7 in JDK 1.7"; - } - if (assumeJava18()) { - return "1.8 in JDK 1.8"; - } - if (assumeJava19()) { - return "1.9 in JDK 1.9"; - } - return ""; - } - - /** - * Whether the selected -target is known to be incompatible with - * the default -source value of the selected JDK's javac. - * - * <p>Assumes it will never be called unless the selected JDK is - * at least Java 1.5.</p> - * - * @param t the -target value, must not be null - */ - private boolean mustSetSourceForTarget(String t) { - if (assumeJava14()) { - return false; - } - if (t.startsWith("1.")) { - t = t.substring(2); - } - return t.equals("1") || t.equals("2") || t.equals("3") || t.equals("4") - || ((t.equals("5") || t.equals("6")) - && !assumeJava15() && !assumeJava16()) - || (t.equals("7") && !assumeJava17()) - || (t.equals("8") && !assumeJava18()) - || (t.equals("9") && !assumeJava19()); - } - - - /** - * Turn the task's attribute for -source into soemthing that is - * understood by all javac's after 1.4. - * - * <p>support for -source 1.1 and -source 1.2 has been added with - * JDK 1.4.2 but isn't present in 1.5.0+</p> - */ - private String adjustSourceValue(final String source) { - return (source.equals("1.1") || source.equals("1.2")) ? "1.3" : source; - } -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java deleted file mode 100644 index 3167cc24..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 gcj compiler. - * This is primarily a cut-and-paste from the jikes. - * - * @since Ant 1.4 - */ -public class Gcj extends DefaultCompilerAdapter { - - /** - * Performs a compile using the gcj compiler. - * @return true if the compilation succeeded - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - Commandline cmd; - attributes.log("Using gcj compiler", Project.MSG_VERBOSE); - cmd = setupGCJCommand(); - - int firstFileName = cmd.size(); - logAndAddFilesToCompile(cmd); - - return - executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; - } - - /** - * Set up the gcj commandline. - * @return the command line - */ - protected Commandline setupGCJCommand() { - Commandline cmd = new Commandline(); - Path classpath = new Path(project); - - // gcj doesn't support bootclasspath dir (-bootclasspath) - // so we'll emulate it for compatibility and convenience. - Path p = getBootClassPath(); - if (p.size() > 0) { - classpath.append(p); - } - - // gcj doesn't support an extension dir (-extdir) - // so we'll emulate it for compatibility and convenience. - if (extdirs != null || includeJavaRuntime) { - 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); - } - - String exec = getJavac().getExecutable(); - cmd.setExecutable(exec == null ? "gcj" : exec); - - if (destDir != null) { - cmd.createArgument().setValue("-d"); - cmd.createArgument().setFile(destDir); - - if (!destDir.exists() - && !(destDir.mkdirs() || destDir.isDirectory())) { - 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("-g1"); - } - if (optimize) { - cmd.createArgument().setValue("-O"); - } - - /** - * gcj should be set for generate class. - * ... if no 'compile to native' argument is passed - */ - if (!isNativeBuild()) { - cmd.createArgument().setValue("-C"); - } - - if (attributes.getSource() != null) { - String source = attributes.getSource(); - cmd.createArgument().setValue("-fsource=" + source); - } - - if (attributes.getTarget() != null) { - String target = attributes.getTarget(); - cmd.createArgument().setValue("-ftarget=" + target); - } - - addCurrentCompilerArgs(cmd); - - return cmd; - } - - /** - * Whether any of the arguments given via <compilerarg> - * implies that compilation to native code is requested. - * @return true if compilation to native code is requested - * @since Ant 1.6.2 - */ - public boolean isNativeBuild() { - boolean nativeBuild = false; - String[] additionalArguments = getJavac().getCurrentCompilerArgs(); - int argsLength = 0; - while (!nativeBuild && argsLength < additionalArguments.length) { - int conflictLength = 0; - while (!nativeBuild - && conflictLength < CONFLICT_WITH_DASH_C.length) { - nativeBuild = (additionalArguments[argsLength].startsWith - (CONFLICT_WITH_DASH_C[conflictLength])); - conflictLength++; - } - argsLength++; - } - return nativeBuild; - } - - private static final String [] CONFLICT_WITH_DASH_C = { - "-o" , "--main=", "-D", "-fjni", "-L" - }; - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java deleted file mode 100644 index 3fd8ccdd..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 java.io.OutputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.LogOutputStream; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * The implementation of the javac compiler for JDK 1.2 - * This is primarily a cut-and-paste from the original javac task before it - * was refactored. - * - * @since Ant 1.3 - * @deprecated Use {@link Javac13} instead. - */ -public class Javac12 extends DefaultCompilerAdapter { - protected static final String CLASSIC_COMPILER_CLASSNAME = "sun.tools.javac.Main"; - - /** - * Run the compilation. - * @return true if the compiler ran with a zero exit result (ok) - * @exception BuildException if the compilation has problems. - */ - public boolean execute() throws BuildException { - attributes.log("Using classic compiler", Project.MSG_VERBOSE); - Commandline cmd = setupJavacCommand(true); - - OutputStream logstr = new LogOutputStream(attributes, Project.MSG_WARN); - try { - // Create an instance of the compiler, redirecting output to - // the project log - Class c = Class.forName(CLASSIC_COMPILER_CLASSNAME); - Constructor cons = - c.getConstructor(new Class[] {OutputStream.class, - String.class}); - Object compiler - = cons.newInstance(new Object[] {logstr, "javac"}); - - // Call the compile() method - Method compile = c.getMethod("compile", - new Class [] {String[].class}); - Boolean ok = - (Boolean) compile.invoke(compiler, - new Object[] {cmd.getArguments()}); - return ok.booleanValue(); - } catch (ClassNotFoundException ex) { - throw new BuildException("Cannot use classic compiler , as it is " - + "not available. \n" - + " A common solution is " - + "to set the environment variable" - + " JAVA_HOME to your jdk directory.\n" - + "It is currently set to \"" - + JavaEnvUtils.getJavaHome() - + "\"", - location); - } catch (Exception ex) { - if (ex instanceof BuildException) { - throw (BuildException) ex; - } else { - throw new BuildException("Error starting classic compiler: ", - ex, location); - } - } finally { - FileUtils.close(logstr); - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java deleted file mode 100644 index acb6a7f0..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 java.lang.reflect.Method; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Commandline; - - -/** - * The implementation of the javac compiler for JDK 1.3 - * This is primarily a cut-and-paste from the original javac task before it - * was refactored. - * - * @since Ant 1.3 - */ -public class Javac13 extends DefaultCompilerAdapter { - - /** - * Integer returned by the "Modern" jdk1.3 compiler to indicate success. - */ - private static final int MODERN_COMPILER_SUCCESS = 0; - - /** - * Run the compilation. - * @return true if the compiler ran with a zero exit result (ok) - * @exception BuildException if the compilation has problems. - */ - public boolean execute() throws BuildException { - attributes.log("Using modern compiler", Project.MSG_VERBOSE); - Commandline cmd = setupModernJavacCommand(); - - // Use reflection to be able to build on all JDKs >= 1.1: - try { - Class c = Class.forName ("com.sun.tools.javac.Main"); - Object compiler = c.newInstance (); - Method compile = c.getMethod ("compile", - new Class [] {(new String [] {}).getClass ()}); - int result = ((Integer) compile.invoke - (compiler, new Object[] {cmd.getArguments()})) - .intValue (); - return (result == MODERN_COMPILER_SUCCESS); - } catch (Exception ex) { - if (ex instanceof BuildException) { - throw (BuildException) ex; - } else { - throw new BuildException("Error starting modern compiler", - ex, location); - } - } - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java deleted file mode 100644 index ab284544..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/JavacExternal.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * Performs a compile using javac externally. - * - * @since Ant 1.4 - */ -public class JavacExternal extends DefaultCompilerAdapter { - - /** - * Performs a compile using the Javac externally. - * @return true if the compilation succeeded - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - attributes.log("Using external javac compiler", Project.MSG_VERBOSE); - - Commandline cmd = new Commandline(); - cmd.setExecutable(getJavac().getJavacExecutable()); - if (!assumeJava11() && !assumeJava12()) { - setupModernJavacCommandlineSwitches(cmd); - } else { - setupJavacCommandlineSwitches(cmd, true); - } - int firstFileName = assumeJava11() ? -1 : cmd.size(); - logAndAddFilesToCompile(cmd); - //On VMS platform, we need to create a special java options file - //containing the arguments and classpath for the javac command. - //The special file is supported by the "-V" switch on the VMS JVM. - if (Os.isFamily("openvms")) { - return execOnVMS(cmd, firstFileName); - } - return - executeExternalCompile(cmd.getCommandline(), firstFileName, - true) - == 0; - } - - /** - * helper method to execute our command on VMS. - * @param cmd - * @param firstFileName - * @return - */ - private boolean execOnVMS(Commandline cmd, int firstFileName) { - File vmsFile = null; - try { - vmsFile = JavaEnvUtils.createVmsJavaOptionFile(cmd.getArguments()); - String[] commandLine = {cmd.getExecutable(), - "-V", - vmsFile.getPath()}; - return 0 == executeExternalCompile(commandLine, - firstFileName, - true); - - } catch (IOException e) { - throw new BuildException("Failed to create a temporary file for \"-V\" switch"); - } finally { - FileUtils.delete(vmsFile); - } - } - -} - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java deleted file mode 100644 index eac1bcfc..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 jikes compiler. - * This is primarily a cut-and-paste from the original javac task before it - * was refactored. - * - * @since Ant 1.3 - */ -public class Jikes extends DefaultCompilerAdapter { - - /** - * Performs a compile using the Jikes compiler from IBM. - * Mostly of this code is identical to doClassicCompile() - * However, it does not support all options like - * extdirs, deprecation and so on, because - * there is no option in jikes and I don't understand - * what they should do. - * - * It has been successfully tested with jikes >1.10. - * @return true if the compilation succeeded - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - attributes.log("Using jikes compiler", Project.MSG_VERBOSE); - - Commandline cmd = new Commandline(); - - // For -sourcepath, use the "sourcepath" value if present. - // Otherwise default to the "srcdir" value. - Path sourcepath = null; - if (compileSourcepath != null) { - sourcepath = compileSourcepath; - } else { - sourcepath = src; - } - // If the buildfile specifies sourcepath="", then don't - // output any sourcepath. - if (sourcepath.size() > 0) { - cmd.createArgument().setValue("-sourcepath"); - cmd.createArgument().setPath(sourcepath); - } - - Path classpath = new Path(project); - - if (bootclasspath == null || bootclasspath.size() == 0) { - // no bootclasspath, therefore, get one from the java runtime - includeJavaRuntime = true; - } else { - // there is a bootclasspath stated. By default, the - // includeJavaRuntime is false. If the user has stated a - // bootclasspath and said to include the java runtime, it's on - // their head! - } - classpath.append(getCompileClasspath()); - - // if the user has set JIKESPATH we should add the contents as well - String jikesPath = System.getProperty("jikes.class.path"); - if (jikesPath != null) { - classpath.append(new Path(project, jikesPath)); - } - - if (extdirs != null && extdirs.size() > 0) { - cmd.createArgument().setValue("-extdirs"); - cmd.createArgument().setPath(extdirs); - } - - String exec = getJavac().getExecutable(); - cmd.setExecutable(exec == null ? "jikes" : exec); - - if (deprecation) { - cmd.createArgument().setValue("-deprecation"); - } - - if (destDir != null) { - cmd.createArgument().setValue("-d"); - cmd.createArgument().setFile(destDir); - } - - cmd.createArgument().setValue("-classpath"); - cmd.createArgument().setPath(classpath); - - if (encoding != null) { - cmd.createArgument().setValue("-encoding"); - cmd.createArgument().setValue(encoding); - } - if (debug) { - String debugLevel = attributes.getDebugLevel(); - if (debugLevel != null) { - cmd.createArgument().setValue("-g:" + debugLevel); - } else { - cmd.createArgument().setValue("-g"); - } - } else { - cmd.createArgument().setValue("-g:none"); - } - if (optimize) { - cmd.createArgument().setValue("-O"); - } - if (verbose) { - cmd.createArgument().setValue("-verbose"); - } - if (depend) { - cmd.createArgument().setValue("-depend"); - } - - if (target != null) { - cmd.createArgument().setValue("-target"); - cmd.createArgument().setValue(target); - } - - addPropertyParams(cmd); - - if (attributes.getSource() != null) { - cmd.createArgument().setValue("-source"); - String source = attributes.getSource(); - if (source.equals("1.1") || source.equals("1.2")) { - // support for -source 1.1 and -source 1.2 has been - // added with JDK 1.4.2, Jikes doesn't like it - attributes.log("Jikes doesn't support '-source " + source - + "', will use '-source 1.3' instead"); - cmd.createArgument().setValue("1.3"); - } else { - cmd.createArgument().setValue(source); - } - } - addCurrentCompilerArgs(cmd); - - int firstFileName = cmd.size(); - - Path boot = getBootClassPath(); - if (boot.size() > 0) { - cmd.createArgument().setValue("-bootclasspath"); - cmd.createArgument().setPath(boot); - } - logAndAddFilesToCompile(cmd); - - return executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; - } - - private void addPropertyParams(Commandline cmd) { - /** - * TODO - * Perhaps we shouldn't use properties for these - * three options (emacs mode, warnings and pedantic), - * but include it in the javac directive? - */ - - /** - * Jikes has the nice feature to print error - * messages in a form readable by emacs, so - * that emacs can directly set the cursor - * to the place, where the error occurred. - */ - String emacsProperty = project.getProperty("build.compiler.emacs"); - if (emacsProperty != null && Project.toBoolean(emacsProperty)) { - cmd.createArgument().setValue("+E"); - } - - /** - * Jikes issues more warnings that javac, for - * example, when you have files in your classpath - * that don't exist. As this is often the case, these - * warning can be pretty annoying. - */ - String warningsProperty = project.getProperty("build.compiler.warnings"); - if (warningsProperty != null) { - attributes.log("!! the build.compiler.warnings property is " + "deprecated. !!", - Project.MSG_WARN); - attributes.log("!! Use the nowarn attribute instead. !!", Project.MSG_WARN); - if (!Project.toBoolean(warningsProperty)) { - cmd.createArgument().setValue("-nowarn"); - } - } - if (attributes.getNowarn()) { - cmd.createArgument().setValue("-nowarn"); - } - - /** - * Jikes can issue pedantic warnings. - */ - String pedanticProperty = project.getProperty("build.compiler.pedantic"); - if (pedanticProperty != null && Project.toBoolean(pedanticProperty)) { - cmd.createArgument().setValue("+P"); - } - - /** - * Jikes supports something it calls "full dependency - * checking", see the jikes documentation for differences - * between -depend and +F. - */ - String fullDependProperty = project.getProperty("build.compiler.fulldepend"); - if (fullDependProperty != null - && Project.toBoolean(fullDependProperty)) { - cmd.createArgument().setValue("+F"); - } - } - -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java deleted file mode 100644 index 85ec4793..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 jvc compiler from microsoft. - * This is primarily a cut-and-paste from the original javac task before it - * was refactored. - * - * @since Ant 1.3 - */ -public class Jvc extends DefaultCompilerAdapter { - - /** - * Run the compilation. - * @return true if the compiler ran with a zero exit result (ok) - * @exception BuildException if the compilation has problems. - */ - public boolean execute() throws BuildException { - attributes.log("Using jvc compiler", Project.MSG_VERBOSE); - - Path classpath = new Path(project); - - // jvc doesn't support bootclasspath dir (-bootclasspath) - // so we'll emulate it for compatibility and convenience. - Path p = getBootClassPath(); - if (p.size() > 0) { - classpath.append(p); - } - - if (includeJavaRuntime) { - // jvc doesn't support an extension dir (-extdir) - // so we'll emulate it for compatibility and convenience. - classpath.addExtdirs(extdirs); - } - - classpath.append(getCompileClasspath()); - - // jvc has no option for source-path so we - // will add it to classpath. - if (compileSourcepath != null) { - classpath.append(compileSourcepath); - } else { - classpath.append(src); - } - - Commandline cmd = new Commandline(); - String exec = getJavac().getExecutable(); - cmd.setExecutable(exec == null ? "jvc" : exec); - - if (destDir != null) { - cmd.createArgument().setValue("/d"); - cmd.createArgument().setFile(destDir); - } - - // Add the Classpath before the "internal" one. - cmd.createArgument().setValue("/cp:p"); - cmd.createArgument().setPath(classpath); - - boolean msExtensions = true; - String mse = getProject().getProperty("build.compiler.jvc.extensions"); - if (mse != null) { - msExtensions = Project.toBoolean(mse); - } - - if (msExtensions) { - // Enable MS-Extensions and ... - cmd.createArgument().setValue("/x-"); - // ... do not display a Message about this. - cmd.createArgument().setValue("/nomessage"); - } - - // Do not display Logo - cmd.createArgument().setValue("/nologo"); - - if (debug) { - cmd.createArgument().setValue("/g"); - } - if (optimize) { - cmd.createArgument().setValue("/O"); - } - if (verbose) { - cmd.createArgument().setValue("/verbose"); - } - - addCurrentCompilerArgs(cmd); - - int firstFileName = cmd.size(); - logAndAddFilesToCompile(cmd); - - return - executeExternalCompile(cmd.getCommandline(), firstFileName, - false) == 0; - } -} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java deleted file mode 100644 index 68b5ba18..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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.taskdefs.ExecuteJava; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; - -/** - * The implementation of the Java compiler for KJC. - * This is primarily a cut-and-paste from Jikes.java and - * DefaultCompilerAdapter. - * - * @since Ant 1.4 - */ -public class Kjc extends DefaultCompilerAdapter { - - /** - * Run the compilation. - * @return true if the compilation succeeded - * @exception BuildException if the compilation has problems. - */ - public boolean execute() throws BuildException { - attributes.log("Using kjc compiler", Project.MSG_VERBOSE); - Commandline cmd = setupKjcCommand(); - cmd.setExecutable("at.dms.kjc.Main"); - ExecuteJava ej = new ExecuteJava(); - ej.setJavaCommand(cmd); - return ej.fork(getJavac()) == 0; - } - - /** - * setup kjc command arguments. - * @return the command line - */ - protected Commandline setupKjcCommand() { - Commandline cmd = new Commandline(); - - // generate classpath, because kjc doesn't support sourcepath. - Path classpath = getCompileClasspath(); - - if (deprecation) { - cmd.createArgument().setValue("-deprecation"); - } - - if (destDir != null) { - cmd.createArgument().setValue("-d"); - cmd.createArgument().setFile(destDir); - } - - // generate the clsspath - cmd.createArgument().setValue("-classpath"); - - Path cp = new Path(project); - - // kjc don't have bootclasspath option. - Path p = getBootClassPath(); - if (p.size() > 0) { - cp.append(p); - } - - if (extdirs != null) { - cp.addExtdirs(extdirs); - } - - cp.append(classpath); - if (compileSourcepath != null) { - cp.append(compileSourcepath); - } else { - cp.append(src); - } - - cmd.createArgument().setPath(cp); - - // kjc-1.5A doesn't support -encoding option now. - // but it will be supported near the feature. - if (encoding != null) { - cmd.createArgument().setValue("-encoding"); - cmd.createArgument().setValue(encoding); - } - - if (debug) { - cmd.createArgument().setValue("-g"); - } - - if (optimize) { - cmd.createArgument().setValue("-O2"); - } - - if (verbose) { - cmd.createArgument().setValue("-verbose"); - } - - addCurrentCompilerArgs(cmd); - - logAndAddFilesToCompile(cmd); - return cmd; - } -} - - diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java deleted file mode 100644 index 0dcc0e4c..00000000 --- a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/compilers/Sj.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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; - -/** - * The implementation of the sj compiler. - * Uses the defaults for DefaultCompilerAdapter - * - * @since Ant 1.4 - */ -public class Sj extends DefaultCompilerAdapter { - - /** - * Performs a compile using the sj compiler from Symantec. - * @return true if the compilation succeeded - * @throws BuildException on error - */ - public boolean execute() throws BuildException { - attributes.log("Using symantec java compiler", Project.MSG_VERBOSE); - - Commandline cmd = setupJavacCommand(); - String exec = getJavac().getExecutable(); - cmd.setExecutable(exec == null ? "sj" : exec); - - int firstFileName = cmd.size() - compileList.length; - - return - executeExternalCompile(cmd.getCommandline(), firstFileName) == 0; - } - - /** - * Returns null since sj either has -g for debug=true or no - * argument at all. - * @return null. - * @since Ant 1.6.3 - */ - protected String getNoDebugArgument() { - return null; - } -} - |