diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/DemuxInputStreamSetter.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/DemuxInputStreamSetter.java deleted file mode 100644 index b053a344bef..00000000000 --- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/DemuxInputStreamSetter.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ant.internal.core.ant; - -import org.apache.tools.ant.DemuxInputStream; -import org.apache.tools.ant.Project; - -/** - * This class exists so that the Ant integration has backwards compatibility with Ant releases previous to 1.6. DemuxInputStream is a new class to Ant - * 1.6. - */ -class DemuxInputStreamSetter { - - protected void remapSystemIn(Project project) { - System.setIn(new DemuxInputStream(project)); - } -} diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ExecutorSetter.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ExecutorSetter.java deleted file mode 100644 index d9c8024333e..00000000000 --- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/ExecutorSetter.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ant.internal.core.ant; - -import org.apache.tools.ant.Executor; -import org.apache.tools.ant.Project; - -/** - * This class exists so that the Ant integration has backwards compatibility with Ant releases previous to 1.6.3. Executors are a new feature of Ant - * 1.6.3. - */ -public class ExecutorSetter { - - protected void setExecutor(Project project) { - Executor executor = new EclipseDefaultExecutor(); - project.setExecutor(executor); - } -} diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.java index 804e2c1029f..9ecb99fd825 100644 --- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.java +++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.java @@ -18,14 +18,9 @@ public class InternalAntMessages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.ant.internal.core.ant.InternalAntMessages";//$NON-NLS-1$ - public static String InternalAntRunner_ant_1_7_needed_for_help_message; - - public static String InternalAntRunner_ant_1_7_needed_for_help_info; - public static String InternalAntRunner_Build_file; public static String InternalAntRunner_Arguments; public static String InternalAntRunner_Unable_to_instantiate_logger; - public static String InternalAntRunner_Could_not_load_the_version_information; public static String InternalAntRunner_Using_file_as_build_log; public static String InternalAntRunner_Could_not_write_to_log_file; public static String InternalAntRunner_BUILD_SUCCESSFUL_1; @@ -37,8 +32,6 @@ public class InternalAntMessages extends NLS { public static String InternalAntRunner_specify_a_classname_using_the_logger_argument; public static String InternalAntRunner_specify_a_log_file_using_the_log_argument; public static String InternalAntRunner_specify_a_buildfile_using_the_buildfile_argument; - public static String InternalAntRunner_Class_not_found_for_task; - public static String InternalAntRunner_Class_not_found_for_type; public static String InternalAntRunner_Only_one_logger_class_may_be_specified; public static String InternalAntRunner_specify_a_classname_the_inputhandler_argument; public static String InternalAntRunner_Only_one_input_handler_class_may_be_specified; @@ -46,15 +39,10 @@ public class InternalAntMessages extends NLS { public static String InternalAntRunner_could_not_load_property_file; public static String InternalAntRunner_handler_does_not_implement_InputHandler5; public static String InternalAntRunner_Unable_to_instantiate_input_handler_class; - public static String InternalAntRunner_Specifying_an_InputHandler_is_an_Ant_1_5_feature; - public static String InternalAntRunner_The_diagnositics_options_is_an_Ant_1_5_feature; - public static String InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature; public static String InternalAntRunner_Default_target_does_not_exist; public static String InternalAntRunner_anthome_must_be_set_to_use_ant_diagnostics; public static String InternalAntRunner_Buildfile_is_not_a_file; public static String InternalAntRunner_find_not_supported; - public static String InternalAntRunner_Error_setting_Ant_task; - public static String InternalAntRunner_Missing_Class; public static String InternalAntRunner_157; public static String InternalAntRunner_unknown_target; @@ -63,8 +51,6 @@ public class InternalAntMessages extends NLS { public static String ProgressBuildListener_Build_cancelled; - public static String InternalProject_could_not_create_type; - public static String InternalAntRunner_SecurityManagerError; static { diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.properties b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.properties index 39171ef2338..6b89648b7d4 100644 --- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.properties +++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntMessages.properties @@ -15,7 +15,6 @@ InternalAntRunner_Build_file=Buildfile: {0} InternalAntRunner_Arguments=Arguments: {0} InternalAntRunner_Unable_to_instantiate_logger=Unable to instantiate logger: {0} -InternalAntRunner_Could_not_load_the_version_information=Could not load the version information: {0} InternalAntRunner_Using_file_as_build_log=Using {0} file as build log. InternalAntRunner_Could_not_write_to_log_file=Cannot write on the specified log file: {0}. Make sure the path exists and you have write permissions. InternalAntRunner_BUILD_SUCCESSFUL_1=BUILD SUCCESSFUL @@ -27,29 +26,19 @@ InternalAntRunner_specify_a_classname_using_the_listener_argument=You must speci InternalAntRunner_specify_a_classname_using_the_logger_argument=You must specify a classname when using the -logger argument InternalAntRunner_specify_a_log_file_using_the_log_argument=You must specify a log file when using the -log argument InternalAntRunner_specify_a_buildfile_using_the_buildfile_argument=You must specify a buildfile when using the -buildfile argument -InternalAntRunner_Class_not_found_for_task=Class {0} not found for task {1} -InternalAntRunner_Class_not_found_for_type=Class {0} not found for type {1} InternalAntRunner_Only_one_logger_class_may_be_specified=Only one logger class may be specified InternalAntRunner_specify_a_classname_the_inputhandler_argument=You must specify a classname when using the -inputhandler argument InternalAntRunner_Only_one_input_handler_class_may_be_specified=Only one input handler class may be specified. InternalAntRunner_specify_a_property_filename_when_using_propertyfile_argument=You must specify a property filename when using the -propertyfile argument InternalAntRunner_could_not_load_property_file=Could not load property file: {0} -InternalAntRunner_ant_1_7_needed_for_help_info=Run with at least Ant 1.7.0 to print project help information -InternalAntRunner_ant_1_7_needed_for_help_message=Run with at least Ant 1.7.0 to print the help message InternalAntRunner_handler_does_not_implement_InputHandler5=The specified input handler class {0} does not implement the org.apache.tools.ant.input.InputHandler interface InternalAntRunner_Unable_to_instantiate_input_handler_class=Unable to instantiate specified input handler class {0} : {1} -InternalAntRunner_Specifying_an_InputHandler_is_an_Ant_1_5_feature=Specifying an InputHandler is an Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this. -InternalAntRunner_The_diagnositics_options_is_an_Ant_1_5_feature=The diagnostics options is an Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this. -InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature=Specifying property files is an Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this. InternalAntRunner_Default_target_does_not_exist=Default target {0}{1}{2} does not exist in this project InternalAntRunner_anthome_must_be_set_to_use_ant_diagnostics=ANT_HOME must be set to use Ant diagnostics InternalAntRunner_Buildfile_is_not_a_file=Buildfile: {0} is not a file InternalAntRunner_find_not_supported=-find not supported.\nCan be emulated using Run As > Ant Build located\nin the Run > External Tools menu -InternalAntRunner_Error_setting_Ant_task=Error setting Ant task {0} -InternalAntRunner_Missing_Class=Could not load a class required for parsing targets InternalAntRunner_157=-lib not supported\nConfigure the Ant runtime classpath using either the\nglobal Ant runtime classpath or the Ant runtime classpath\n for this particular build InternalAntRunner_unknown_target=Unknown target: {0} InternalAntRunner_no_known_target=No known target specified. ProgressBuildListener_Build_cancelled=Build cancelled. -InternalProject_could_not_create_type=Could not create type {0} due to {1} InternalAntRunner_SecurityManagerError=Setting Security Manager is not supported diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java index 704c4d90394..f7ca61e0431 100644 --- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java +++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java @@ -38,14 +38,15 @@ import java.util.Vector; import org.apache.tools.ant.AntTypeDefinition; -import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.ComponentHelper; import org.apache.tools.ant.DefaultLogger; +import org.apache.tools.ant.DemuxInputStream; import org.apache.tools.ant.DemuxOutputStream; import org.apache.tools.ant.Diagnostics; +import org.apache.tools.ant.Executor; import org.apache.tools.ant.Main; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; @@ -75,7 +76,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.variables.VariablesPlugin; import org.osgi.framework.Bundle; -import org.osgi.framework.Version; /** * Eclipse application entry point into Ant. Derived from the original Ant Main class to ensure that the functionality is equivalent when running in @@ -116,11 +116,6 @@ private static boolean isSecurityManagerAllowed() { private BuildLogger buildLogger = null; - /** - * Cache of the Ant version number when it has been loaded - */ - private String antVersionNumber = null; - /** Current message output status. Follows Project.MSG_XXX */ private int messageOutputLevel = Project.MSG_INFO; @@ -324,57 +319,25 @@ private void setGlobalProperties(Project project, boolean substituteVariables) { private void setTasks(Project project) { List tasks = AntCorePlugin.getPlugin().getPreferences().getTasks(); for (Task task : tasks) { - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - AntTypeDefinition def = new AntTypeDefinition(); - String name = ProjectHelper.genComponentName(task.getURI(), task.getTaskName()); - def.setName(name); - def.setClassName(task.getClassName()); - def.setClassLoader(this.getClass().getClassLoader()); - def.setAdaptToClass(org.apache.tools.ant.Task.class); - def.setAdapterClass(TaskAdapter.class); - ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def); - } else { - try { - Class taskClass = Class.forName(task.getClassName()); - if (isVersionCompatible("1.5")) { //$NON-NLS-1$ - try { - project.checkTaskClass(taskClass); - } - catch (BuildException e) { - IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Error_setting_Ant_task, task.getTaskName()), e); - AntCorePlugin.getPlugin().getLog().log(status); - continue; - } - } - project.addTaskDefinition(task.getTaskName(), taskClass); - } - catch (ClassNotFoundException e) { - IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Class_not_found_for_task, task.getClassName(), task.getTaskName()), e); - AntCorePlugin.getPlugin().getLog().log(status); - } - } + AntTypeDefinition def = new AntTypeDefinition(); + String name = ProjectHelper.genComponentName(task.getURI(), task.getTaskName()); + def.setName(name); + def.setClassName(task.getClassName()); + def.setClassLoader(this.getClass().getClassLoader()); + def.setAdaptToClass(org.apache.tools.ant.Task.class); + def.setAdapterClass(TaskAdapter.class); + ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def); } } private void setTypes(Project project) { for (Type type : AntCorePlugin.getPlugin().getPreferences().getTypes()) { - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - AntTypeDefinition def = new AntTypeDefinition(); - String name = ProjectHelper.genComponentName(type.getURI(), type.getTypeName()); - def.setName(name); - def.setClassName(type.getClassName()); - def.setClassLoader(this.getClass().getClassLoader()); - ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def); - } else { - try { - Class typeClass = Class.forName(type.getClassName()); - project.addDataTypeDefinition(type.getTypeName(), typeClass); - } - catch (ClassNotFoundException e) { - IStatus status = new Status(IStatus.ERROR, AntCorePlugin.PI_ANTCORE, AntCorePlugin.ERROR_RUNNING_BUILD, MessageFormat.format(InternalAntMessages.InternalAntRunner_Class_not_found_for_type, type.getClassName(), type.getTypeName()), e); - AntCorePlugin.getPlugin().getLog().log(status); - } - } + AntTypeDefinition def = new AntTypeDefinition(); + String name = ProjectHelper.genComponentName(type.getURI(), type.getTypeName()); + def.setName(name); + def.setClassName(type.getClassName()); + def.setClassLoader(this.getClass().getClassLoader()); + ComponentHelper.getComponentHelper(project).addDataTypeDefinition(def); } } @@ -393,21 +356,9 @@ protected void parseBuildFile(Project project) { throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Buildfile_is_not_a_file, buildFile.getAbsolutePath())); } - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - parseBuildFile(project, buildFile); - } else { - ProjectHelper helper = ProjectHelper.getProjectHelper(); - project.addReference("ant.projectHelper", helper); //$NON-NLS-1$ - helper.parse(project, buildFile); - } - } - - /** - * @deprecated support for Ant older than 1.5 - */ - @Deprecated - private void parseBuildFile(Project project, File buildFile) { - ProjectHelper.configureProject(project, buildFile); + ProjectHelper helper = ProjectHelper.getProjectHelper(); + project.addReference("ant.projectHelper", helper); //$NON-NLS-1$ + helper.parse(project, buildFile); } /** @@ -420,7 +371,7 @@ private void parseBuildFile(Project project, File buildFile) { public List getTargets() { try { setJavaClassPath(); - Project antProject = getProject(); + Project antProject = new InternalProject2(); processAntHome(false); antProject.init(); setTypes(antProject); @@ -432,9 +383,7 @@ public List getTargets() { } setProperties(antProject, false); - if (isVersionCompatible("1.5")) { //$NON-NLS-1$ - new InputHandlerSetter().setInputHandler(antProject, "org.eclipse.ant.internal.core.ant.NullInputHandler"); //$NON-NLS-1$ - } + new InputHandlerSetter().setInputHandler(antProject, "org.eclipse.ant.internal.core.ant.NullInputHandler"); //$NON-NLS-1$ parseBuildFile(antProject); defaultTarget = antProject.getDefaultTarget(); Hashtable projectTargets = antProject.getTargets(); @@ -480,18 +429,14 @@ public List getTargets() { private List getTargetNames() { try { setJavaClassPath(); - Project antProject; - - antProject = getProject(); + Project antProject = new InternalProject2(); processAntHome(false); antProject.init(); setTypes(antProject); processProperties(AntCoreUtil.getArrayList(extraArguments)); setProperties(antProject, false); - if (isVersionCompatible("1.5")) { //$NON-NLS-1$ - new InputHandlerSetter().setInputHandler(antProject, "org.eclipse.ant.internal.core.ant.NullInputHandler"); //$NON-NLS-1$ - } + new InputHandlerSetter().setInputHandler(antProject, "org.eclipse.ant.internal.core.ant.NullInputHandler"); //$NON-NLS-1$ parseBuildFile(antProject); Hashtable projectTargets = antProject.getTargets(); ArrayList names = new ArrayList<>(); @@ -510,21 +455,6 @@ private List getTargetNames() { } } - private Project getProject() { - Project antProject; - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - // in Ant version 1.6 or greater all tasks can exist outside the scope of a target - if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$ - antProject = new InternalProject2(); - } else { - antProject = new Project(); - } - } else { - antProject = new InternalProject(); - } - return antProject; - } - /** * Returns the default target name that was last computed or null if no default target has been computed. * @@ -596,9 +526,8 @@ public void run(Object argArray) throws Exception { */ private void run(List argList) { setCurrentProject(new Project()); - if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$ - new ExecutorSetter().setExecutor(currentProject); - } + Executor executor = new EclipseDefaultExecutor(); + currentProject.setExecutor(executor); Throwable error = null; PrintStream originalErr = System.err; PrintStream originalOut = System.out; @@ -626,12 +555,12 @@ private void run(List argList) { addInputHandler(getCurrentProject()); - remapSystemIn(); + System.setIn(new DemuxInputStream(currentProject)); System.setOut(new PrintStream(new DemuxOutputStream(getCurrentProject(), false))); System.setErr(new PrintStream(new DemuxOutputStream(getCurrentProject(), true))); if (!projectHelp) { - fireBuildStarted(getCurrentProject()); + getCurrentProject().fireBuildStarted(); } if (fEarlyErrorMessage != null) { @@ -663,16 +592,14 @@ private void run(List argList) { // needs to occur after processCommandLine(List) if (allowInput && (inputHandlerClassname != null && inputHandlerClassname.length() > 0)) { - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=182577 - // getCurrentProject().setDefaultInputStream(originalIn); - System.getProperties().remove("eclipse.ant.noInput"); //$NON-NLS-1$ - } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=182577 + // getCurrentProject().setDefaultInputStream(originalIn); + System.getProperties().remove("eclipse.ant.noInput"); //$NON-NLS-1$ } else { // set the system property that any input handler // can check to see if handling input is allowed System.setProperty("eclipse.ant.noInput", "true"); //$NON-NLS-1$//$NON-NLS-2$ - if (isVersionCompatible("1.5") && (inputHandlerClassname == null || inputHandlerClassname.length() == 0)) { //$NON-NLS-1$ + if (inputHandlerClassname == null || inputHandlerClassname.length() == 0) { InputHandlerSetter setter = new InputHandlerSetter(); setter.setInputHandler(getCurrentProject(), "org.eclipse.ant.internal.core.ant.FailInputHandler"); //$NON-NLS-1$ } @@ -684,21 +611,14 @@ private void run(List argList) { setTasks(getCurrentProject()); setTypes(getCurrentProject()); - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - getCurrentProject().setKeepGoingMode(keepGoing); - } + getCurrentProject().setKeepGoingMode(keepGoing); parseBuildFile(getCurrentProject()); } createMonitorBuildListener(getCurrentProject()); if (projectHelp) { - if (isVersionCompatible("1.7")) { //$NON-NLS-1$ - new EclipseMainHelper().runProjectHelp(getBuildFileLocation(), getCurrentProject()); - return; - } - logMessage(currentProject, InternalAntMessages.InternalAntRunner_ant_1_7_needed_for_help_info, Project.MSG_ERR); - executed = false; + new EclipseMainHelper().runProjectHelp(getBuildFileLocation(), getCurrentProject()); return; } @@ -715,9 +635,6 @@ private void run(List argList) { if (targets.isEmpty() && dtarget != null) { targets.add(dtarget); } - if (!isVersionCompatible("1.6.3")) { //$NON-NLS-1$ - getCurrentProject().addReference(IAntCoreConstants.TARGET_VECTOR_NAME, targets); - } getCurrentProject().executeTargets(targets); } catch (OperationCanceledException e) { @@ -766,17 +683,6 @@ private void run(List argList) { } } - /** - * Re-maps {@link System#in} to the Ant input stream setter - */ - protected void remapSystemIn() { - if (!isVersionCompatible("1.6")) { //$NON-NLS-1$ - return; - } - DemuxInputStreamSetter setter = new DemuxInputStreamSetter(); - setter.remapSystemIn(currentProject); - } - private void processAntHome(boolean finished) { AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences(); String antHome = prefs.getAntHome(); @@ -826,28 +732,14 @@ protected BuildLogger createLogger() { buildLogger.setOutputPrintStream(out); buildLogger.setErrorPrintStream(err); buildLogger.setEmacsMode(emacsMode); - if (buildLogger instanceof AbstractEclipseBuildLogger) { - ((AbstractEclipseBuildLogger) buildLogger).configure(userProperties); + if (buildLogger instanceof AbstractEclipseBuildLogger eclipseLogger) { + eclipseLogger.configure(userProperties); } } return buildLogger; } - /** - * Project.fireBuildStarted is protected in Ant earlier than 1.5.*. Provides backwards compatibility with old Ant installs. - */ - protected void fireBuildStarted(Project project) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - BuildEvent event = new BuildEvent(project); - for (BuildListener listener : project.getBuildListeners()) { - listener.buildStarted(event); - } - } else { - project.fireBuildStarted(); - } - } - /** * Sends the the event to the backing project that the build has completed */ @@ -869,15 +761,7 @@ protected void fireBuildFinished(Project project, Throwable error) { if (error == null && executed) { logMessage(project, InternalAntMessages.InternalAntRunner_BUILD_SUCCESSFUL_1, messageOutputLevel); } - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - BuildEvent event = new BuildEvent(project); - event.setException(error); - for (BuildListener listener : project.getBuildListeners()) { - listener.buildFinished(event); - } - } else { - project.fireBuildFinished(error); - } + project.fireBuildFinished(error); } private boolean usingXmlLogger() { @@ -993,38 +877,6 @@ public void setExecutionTargets(String[] executionTargets) { } } - /* - * Returns a String representation of the Ant version number as specified in the version.txt file. - */ - protected String getAntVersionNumber() throws BuildException { - if (antVersionNumber == null) { - try (InputStream in = Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt")) { //$NON-NLS-1$ - Properties props = new Properties(); - props.load(in); - String versionNumber = props.getProperty("VERSION"); //$NON-NLS-1$ - antVersionNumber = versionNumber; - } - catch (IOException ioe) { - throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, ioe.getMessage()), ioe); - } - catch (NullPointerException npe) { - throw new BuildException(MessageFormat.format(InternalAntMessages.InternalAntRunner_Could_not_load_the_version_information, npe.getMessage()), npe); - } - } - return antVersionNumber; - } - - /* - * Returns whether the given version is compatible with the current Ant version. A version is compatible if it is less than or equal to the - * current version. - */ - protected boolean isVersionCompatible(String comparison) { - String version = getAntVersionNumber(); - Version osgiVersion = new Version(version); - Version osgiComparison = new Version(comparison); - return osgiVersion.compareTo(osgiComparison) >= 0; - } - /** * Pre-processes the raw command line to set up input handling and logging.
*
@@ -1066,9 +918,6 @@ protected boolean preprocessCommandLine(List commands) { arg = AntCoreUtil.getArgument(commands, "-inputhandler"); //$NON-NLS-1$ if (arg != null) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - throw new BuildException(InternalAntMessages.InternalAntRunner_Specifying_an_InputHandler_is_an_Ant_1_5_feature); - } if (arg.length() == 0) { throw new BuildException(InternalAntMessages.InternalAntRunner_specify_a_classname_the_inputhandler_argument); } @@ -1115,11 +964,7 @@ protected boolean preprocessCommandLine(List commands) { */ private boolean processCommandLine(List commands) { if (commands.remove("-help") || commands.remove("-h")) { //$NON-NLS-1$ //$NON-NLS-2$ - if (isVersionCompatible("1.7")) { //$NON-NLS-1$ - new EclipseMainHelper().runUsage(getBuildFileLocation(), currentProject); - } else { - logMessage(currentProject, InternalAntMessages.InternalAntRunner_ant_1_7_needed_for_help_message, Project.MSG_WARN); - } + new EclipseMainHelper().runUsage(getBuildFileLocation(), currentProject); return false; } @@ -1150,9 +995,6 @@ private boolean processCommandLine(List commands) { } if (commands.remove("-diagnostics")) { //$NON-NLS-1$ - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - throw new BuildException(InternalAntMessages.InternalAntRunner_The_diagnositics_options_is_an_Ant_1_5_feature); - } try { Diagnostics.doReport(System.out); } @@ -1197,18 +1039,16 @@ private boolean processCommandLine(List commands) { } setBuildFileLocation(arg); } - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$ - keepGoing = true; - } - if (commands.remove("-noinput")) { //$NON-NLS-1$ - allowInput = false; - } - arg = AntCoreUtil.getArgument(commands, "-lib"); //$NON-NLS-1$ - if (arg != null) { - logMessage(currentProject, InternalAntMessages.InternalAntRunner_157, Project.MSG_ERR); - return false; - } + if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$ + keepGoing = true; + } + if (commands.remove("-noinput")) { //$NON-NLS-1$ + allowInput = false; + } + arg = AntCoreUtil.getArgument(commands, "-lib"); //$NON-NLS-1$ + if (arg != null) { + logMessage(currentProject, InternalAntMessages.InternalAntRunner_157, Project.MSG_ERR); + return false; } arg = AntCoreUtil.getArgument(commands, "-find"); //$NON-NLS-1$ @@ -1335,10 +1175,6 @@ private boolean processProperties(List commands) { // MULTIPLE property files are allowed String arg = AntCoreUtil.getArgument(commands, "-propertyfile"); //$NON-NLS-1$ while (arg != null) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - fEarlyErrorMessage = InternalAntMessages.InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature; - break; - } if (arg.length() == 0) { fEarlyErrorMessage = InternalAntMessages.InternalAntRunner_specify_a_property_filename_when_using_propertyfile_argument; exceptionToBeThrown = true; @@ -1351,14 +1187,10 @@ private boolean processProperties(List commands) { String[] globalPropertyFiles = AntCorePlugin.getPlugin().getPreferences().getCustomPropertyFiles(); if (globalPropertyFiles.length > 0) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - fEarlyErrorMessage = InternalAntMessages.InternalAntRunner_Specifying_property_files_is_a_Ant_1_5_feature; - } else { - if (propertyFiles == null) { - propertyFiles = new ArrayList<>(globalPropertyFiles.length); - } - propertyFiles.addAll(Arrays.asList(globalPropertyFiles)); + if (propertyFiles == null) { + propertyFiles = new ArrayList<>(globalPropertyFiles.length); } + propertyFiles.addAll(Arrays.asList(globalPropertyFiles)); } if (propertyFiles != null && !propertyFiles.isEmpty()) { @@ -1457,7 +1289,7 @@ protected void loadPropertyFiles() { * if a specified InputHandler implementation could not be loaded. */ protected void addInputHandler(Project project) { - if (!isVersionCompatible("1.5") || (inputHandlerClassname != null && inputHandlerClassname.length() == 0)) { //$NON-NLS-1$ + if (inputHandlerClassname != null && inputHandlerClassname.length() == 0) { return; } InputHandlerSetter setter = new InputHandlerSetter(); diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java deleted file mode 100644 index 57512ec0d61..00000000000 --- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalProject.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - derived implementation - *******************************************************************************/ - -package org.eclipse.ant.internal.core.ant; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; // can't use ICU, ant build script -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Properties; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.ProjectComponent; - -/** - * A subclass of Project to facilitate "faster" parsing with less garbage generated. This class is not used on Ant 1.6 and newer due to the - * improvements in lazy loading of these Ant versions. - * - * Only three tasks are loaded (property, taskdef and typedef: three tasks that can be defined outside of a target on Ant 1.5.1 or older). - * - * Datatypes are loaded if requested. - * - * Derived from the original Ant Project class - */ -public class InternalProject extends Project { - - private Hashtable> typeNameToClass = null; - - public InternalProject() { - super(); - } - - @Override - public void init() throws BuildException { - setJavaVersionProperty(); - - try { - Class taskClass = Class.forName("org.apache.tools.ant.taskdefs.Property"); //$NON-NLS-1$ - addTaskDefinition("property", taskClass); //$NON-NLS-1$ - taskClass = Class.forName("org.apache.tools.ant.taskdefs.Typedef"); //$NON-NLS-1$ - addTaskDefinition("typedef", taskClass); //$NON-NLS-1$ - taskClass = Class.forName("org.apache.tools.ant.taskdefs.Taskdef"); //$NON-NLS-1$ - addTaskDefinition("taskdef", taskClass); //$NON-NLS-1$ - } - catch (NoClassDefFoundError e) { - throw new BuildException(InternalAntMessages.InternalAntRunner_Missing_Class, e); - } - catch (ClassNotFoundException c) { - throw new BuildException(InternalAntMessages.InternalAntRunner_Missing_Class, c); - } - - setSystemProperties(); - } - - @Override - public Object createDataType(String typeName) throws BuildException { - if (typeNameToClass == null) { - initializeTypes(); - } - Class typeClass = typeNameToClass.get(typeName); - - if (typeClass == null) { - return null; - } - - Throwable thrown = null; - try { - Constructor ctor = null; - boolean noArg = false; - // DataType can have a "no arg" constructor or take a single - // Project argument. - try { - ctor = typeClass.getConstructor(); - noArg = true; - } - catch (NoSuchMethodException nse) { - ctor = typeClass.getConstructor(Project.class); - noArg = false; - } - - Object o = null; - if (noArg) { - o = ctor.newInstance(); - } else { - o = ctor.newInstance(this); - } - if (o instanceof ProjectComponent) { - ((ProjectComponent) o).setProject(this); - } - return o; - } - catch (InvocationTargetException ite) { - thrown = ite.getTargetException(); - } - catch (IllegalArgumentException e) { - thrown = e; - } - catch (InstantiationException e) { - thrown = e; - } - catch (IllegalAccessException e) { - thrown = e; - } - catch (NoSuchMethodException nse) { - thrown = nse; - } - catch (NoClassDefFoundError ncdfe) { - thrown = ncdfe; - } - if (thrown != null) { - String message = MessageFormat.format(InternalAntMessages.InternalProject_could_not_create_type, typeName, thrown.toString()); - throw new BuildException(message, thrown); - } - // this line is actually unreachable - return null; - } - - /** - * Initialize the mapping of data type name to data type classname - */ - private void initializeTypes() { - typeNameToClass = new Hashtable<>(18); - try (InputStream in = Project.class.getResourceAsStream("/org/apache/tools/ant/types/defaults.properties")) { //$NON-NLS-1$ - if (in == null) { - return; - } - Properties props = new Properties(); - props.load(in); - Enumeration enumeration = props.propertyNames(); - while (enumeration.hasMoreElements()) { - String typeName = (String) enumeration.nextElement(); - String className = props.getProperty(typeName); - try { - Class typeClass = Class.forName(className); - typeNameToClass.put(typeName, typeClass); - } - catch (NoClassDefFoundError e) { - // ignore - } - catch (ClassNotFoundException c) { - // ignore - } - } - } - catch (IOException ioe) { - return; - } - - } - - @Override - public Hashtable> getDataTypeDefinitions() { - if (typeNameToClass == null) { - initializeTypes(); - } - return typeNameToClass; - } - - @Override - public void addDataTypeDefinition(String typeName, Class typeClass) { - getDataTypeDefinitions(); - typeNameToClass.put(typeName, typeClass); - } -} diff --git a/ant/org.eclipse.ant.launching/lib/remote.jar b/ant/org.eclipse.ant.launching/lib/remote.jar index 44fd3cd4bf8..c4856f4f877 100644 Binary files a/ant/org.eclipse.ant.launching/lib/remote.jar and b/ant/org.eclipse.ant.launching/lib/remote.jar differ diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/DemuxInputStreamSetter.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/DemuxInputStreamSetter.java deleted file mode 100644 index 612fb37a8d7..00000000000 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/DemuxInputStreamSetter.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ant.internal.launching.remote; - -import org.apache.tools.ant.DemuxInputStream; -import org.apache.tools.ant.Project; - -/** - * This class exists so that the Ant integration has backwards compatibility with Ant releases previous to 1.6. DemuxInputStream is a new class to Ant - * 1.6. - */ -class DemuxInputStreamSetter { - - protected void remapSystemIn(Project project) { - System.setIn(new DemuxInputStream(project)); - } -} diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/ExecutorSetter.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/ExecutorSetter.java deleted file mode 100644 index 169ed63d785..00000000000 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/ExecutorSetter.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ant.internal.launching.remote; - -import org.apache.tools.ant.Executor; -import org.apache.tools.ant.Project; - -/** - * This class exists so that the Ant integration has backwards compatibility with Ant releases previous to 1.6.3. Executors are a new feature of Ant - * 1.6.3. - */ -public class ExecutorSetter { - - protected void setExecutor(Project project) { - Executor executor = new EclipseDefaultExecutor(); - project.setExecutor(executor); - } -} diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java index bd615502c21..195b2d8bb20 100644 --- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java +++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2025 IBM Corporation and others. + * Copyright (c) 2000, 2026 IBM Corporation and others. * Portions Copyright 2000-2005 The Apache Software Foundation * * This program and the accompanying materials are made @@ -29,20 +29,19 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.NoSuchElementException; import java.util.Properties; -import java.util.StringTokenizer; import java.util.Vector; import org.apache.tools.ant.AntTypeDefinition; -import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.BuildLogger; import org.apache.tools.ant.ComponentHelper; import org.apache.tools.ant.DefaultLogger; +import org.apache.tools.ant.DemuxInputStream; import org.apache.tools.ant.DemuxOutputStream; import org.apache.tools.ant.Diagnostics; +import org.apache.tools.ant.Executor; import org.apache.tools.ant.Main; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; @@ -96,10 +95,6 @@ private static boolean isSecurityManagerAllowed() { private Map eclipseSpecifiedTasks; private Map eclipseSpecifiedTypes; - /** - * Cache of the Ant version number when it has been loaded - */ - private String antVersionNumber = null; /** Our current message output status. Follows Project.MSG_XXX */ private int messageOutputLevel = Project.MSG_INFO; @@ -224,21 +219,9 @@ private void parseBuildFile(Project project) { buildFile.getAbsolutePath())); } - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - parseBuildFile(project, buildFile); - } else { - ProjectHelper helper = ProjectHelper.getProjectHelper(); - project.addReference("ant.projectHelper", helper); //$NON-NLS-1$ - helper.parse(project, buildFile); - } - } - - /** - * @deprecated support for Ant older than 1.5 - */ - @Deprecated - private void parseBuildFile(Project project, File buildFile) { - ProjectHelper.configureProject(project, buildFile); + ProjectHelper helper = ProjectHelper.getProjectHelper(); + project.addReference("ant.projectHelper", helper); //$NON-NLS-1$ + helper.parse(project, buildFile); } private void printArguments(Project project) { @@ -356,9 +339,8 @@ private void printTargets(Project project, List names, List desc @SuppressWarnings("removal") // SecurityManager private void run(List argList) { setCurrentProject(new Project()); - if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$ - new ExecutorSetter().setExecutor(getCurrentProject()); - } + Executor executor = new EclipseDefaultExecutor(); + getCurrentProject().setExecutor(executor); Throwable error = null; PrintStream originalErr = System.err; PrintStream originalOut = System.out; @@ -385,12 +367,12 @@ private void run(List argList) { addInputHandler(getCurrentProject()); - remapSystemIn(); + System.setIn(new DemuxInputStream(getCurrentProject())); System.setOut(new PrintStream(new DemuxOutputStream(getCurrentProject(), false))); System.setErr(new PrintStream(new DemuxOutputStream(getCurrentProject(), true))); if (!projectHelp) { - fireBuildStarted(getCurrentProject()); + getCurrentProject().fireBuildStarted(); } if (fEarlyErrorMessage != null) { @@ -422,14 +404,12 @@ private void run(List argList) { // needs to occur after processCommandLine(List) if (allowInput && (inputHandlerClassname != null && inputHandlerClassname.length() > 0)) { - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - getCurrentProject().setDefaultInputStream(originalIn); - } + getCurrentProject().setDefaultInputStream(originalIn); } else { // set the system property that any input handler // can check to see if handling input is allowed System.setProperty("eclipse.ant.noInput", "true"); //$NON-NLS-1$//$NON-NLS-2$ - if (isVersionCompatible("1.5") && (inputHandlerClassname == null || inputHandlerClassname.length() == 0)) { //$NON-NLS-1$ + if (inputHandlerClassname == null || inputHandlerClassname.length() == 0) { InputHandlerSetter setter = new InputHandlerSetter(); setter.setInputHandler(getCurrentProject(), "org.eclipse.ant.internal.launching.remote.inputhandler.FailInputHandler"); //$NON-NLS-1$ } @@ -440,9 +420,7 @@ private void run(List argList) { setTasks(); setTypes(); - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - getCurrentProject().setKeepGoingMode(keepGoing); - } + getCurrentProject().setKeepGoingMode(keepGoing); parseBuildFile(getCurrentProject()); @@ -469,9 +447,6 @@ private void run(List argList) { if (targets.isEmpty() && getCurrentProject().getDefaultTarget() != null) { targets.add(getCurrentProject().getDefaultTarget()); } - if (!isVersionCompatible("1.6.3")) { //$NON-NLS-1$ - getCurrentProject().addReference(IAntCoreConstants.TARGET_VECTOR_NAME, targets); - } getCurrentProject().executeTargets(targets); } catch (AntSecurityException e) { @@ -510,25 +485,13 @@ private void setTasks() { taskName = entry.getKey(); taskClassName = entry.getValue(); - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - AntTypeDefinition def = new AntTypeDefinition(); - def.setName(taskName); - def.setClassName(taskClassName); - def.setClassLoader(this.getClass().getClassLoader()); - def.setAdaptToClass(Task.class); - def.setAdapterClass(TaskAdapter.class); - ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def); - } else { - try { - Class taskClass = Class.forName(taskClassName); - getCurrentProject().addTaskDefinition(taskName, taskClass); - } - catch (ClassNotFoundException e) { - String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.161"), taskClassName, //$NON-NLS-1$ - taskName); - getCurrentProject().log(message, Project.MSG_WARN); - } - } + AntTypeDefinition def = new AntTypeDefinition(); + def.setName(taskName); + def.setClassName(taskClassName); + def.setClassLoader(this.getClass().getClassLoader()); + def.setAdaptToClass(Task.class); + def.setAdapterClass(TaskAdapter.class); + ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def); } } } @@ -540,35 +503,15 @@ private void setTypes() { for (Entry entry : eclipseSpecifiedTypes.entrySet()) { typeName = entry.getKey(); typeClassName = entry.getValue(); - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - AntTypeDefinition def = new AntTypeDefinition(); - def.setName(typeName); - def.setClassName(typeClassName); - def.setClassLoader(this.getClass().getClassLoader()); - ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def); - } else { - try { - Class typeClass = Class.forName(typeClassName); - getCurrentProject().addDataTypeDefinition(typeName, typeClass); - } - catch (ClassNotFoundException e) { - String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.162"), typeClassName, //$NON-NLS-1$ - typeName); - getCurrentProject().log(message, Project.MSG_WARN); - } - } + AntTypeDefinition def = new AntTypeDefinition(); + def.setName(typeName); + def.setClassName(typeClassName); + def.setClassLoader(this.getClass().getClassLoader()); + ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def); } } } - private void remapSystemIn() { - if (!isVersionCompatible("1.6")) { //$NON-NLS-1$ - return; - } - DemuxInputStreamSetter setter = new DemuxInputStreamSetter(); - setter.remapSystemIn(getCurrentProject()); - } - /** * Creates and returns the default build logger for logging build events to the ant log. * @@ -606,33 +549,11 @@ private BuildLogger createLogger() { return buildLogger; } - /** - * Project.fireBuildStarted is protected in Ant earlier than 1.5.*. Provides backwards compatibility with old Ant installs. - */ - private void fireBuildStarted(Project project) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - BuildEvent event = new BuildEvent(project); - for (BuildListener listener : project.getBuildListeners()) { - listener.buildStarted(event); - } - } else { - project.fireBuildStarted(); - } - } - private void fireBuildFinished(Project project, Throwable error) { if (error == null && scriptExecuted) { logMessage(project, RemoteAntMessages.getString("InternalAntRunner.BUILD_SUCCESSFUL_1"), messageOutputLevel); //$NON-NLS-1$ } - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - BuildEvent event = new BuildEvent(project); - event.setException(error); - for (BuildListener listener : project.getBuildListeners()) { - listener.buildFinished(event); - } - } else { - project.fireBuildFinished(error); - } + project.fireBuildFinished(error); } private void logMessage(Project project, String message, int priority) { @@ -674,128 +595,6 @@ private void setMessageOutputLevel(int level) { } } - /** - * @return a String representation of the Ant version number as specified in the version.txt file - */ - private String getAntVersionNumber() throws BuildException { - if (antVersionNumber == null) { - try { - InputStream in = Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt");//$NON-NLS-1$ - Properties props = new Properties(); - props.load(in); - String versionNumber = props.getProperty("VERSION"); //$NON-NLS-1$ - antVersionNumber = versionNumber; - } - catch (IOException ioe) { - throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._{0}_9"), ioe.getMessage()), ioe); //$NON-NLS-1$ - } - catch (NullPointerException npe) { - throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._10"), npe); //$NON-NLS-1$ - } - } - return antVersionNumber; - } - - /** - * Returns whether the given version is compatible with the current Ant version. A version is compatible if it is less than or equal to the - * current version. - */ - private boolean isVersionCompatible(String comparison) { - String version = getAntVersionNumber(); - Version osgiVersion = new Version(version); - Version osgiComparison = new Version(comparison); - return osgiVersion.compareTo(osgiComparison) >= 0; - } - - /** - * Copy of org.osgi.framework.Version. - *

- * We can't know how Ant version numbers will evolve in the future, but the OSGi version number format looks like a good bet. - */ - private static class Version { - private final int major; - private final int minor; - private final int micro; - private final String qualifier; - private static final String SEPARATOR = "."; //$NON-NLS-1$ - - public int compareTo(Version other) { - if (other == this) { // quick test - return 0; - } - - int result = major - other.major; - if (result != 0) { - return result; - } - - result = minor - other.minor; - if (result != 0) { - return result; - } - - result = micro - other.micro; - if (result != 0) { - return result; - } - - return qualifier.compareTo(other.qualifier); - } - - public Version(String version) { - int maj = 0; - int min = 0; - int mic = 0; - String qual = ""; //$NON-NLS-1$ - - try { - StringTokenizer st = new StringTokenizer(version, SEPARATOR, true); - maj = parseInt(st.nextToken(), version); - - if (st.hasMoreTokens()) { // minor - st.nextToken(); // consume delimiter - min = parseInt(st.nextToken(), version); - - if (st.hasMoreTokens()) { // micro - st.nextToken(); // consume delimiter - mic = parseInt(st.nextToken(), version); - - if (st.hasMoreTokens()) { // qualifier separator - st.nextToken(); // consume delimiter - qual = st.nextToken(""); // remaining string //$NON-NLS-1$ - - if (st.hasMoreTokens()) { // fail safe - throw new IllegalArgumentException("invalid version \"" + version + "\": invalid format"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } - } - catch (NoSuchElementException e) { - IllegalArgumentException iae = new IllegalArgumentException("invalid version \"" + version + "\": invalid format");//$NON-NLS-1$ //$NON-NLS-2$ - iae.initCause(e); - throw iae; - } - - major = maj; - minor = min; - micro = mic; - qualifier = qual; - // validate(); - } - - private int parseInt(String value, String version) { - try { - return Integer.parseInt(value); - } - catch (NumberFormatException e) { - IllegalArgumentException iae = new IllegalArgumentException("invalid version \"" + version + "\": non-numeric \"" + value + "\""); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - iae.initCause(e); - throw iae; - } - } - } - private boolean preprocessCommandLine(List commands) { String arg = getArgument(commands, "-listener"); //$NON-NLS-1$ @@ -871,9 +670,6 @@ private boolean processCommandLine(List commands) { } if (commands.remove("-diagnostics")) { //$NON-NLS-1$ - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.The_diagnositics_options_is_an_Ant_1.5.*_feature._Please_update_your_Ant_classpath_to_include_an_Ant_version_greater_than_this._4")); //$NON-NLS-1$ - } try { Diagnostics.doReport(System.out); } @@ -921,18 +717,16 @@ private boolean processCommandLine(List commands) { setBuildFileLocation(arg); } - if (isVersionCompatible("1.6")) { //$NON-NLS-1$ - if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$ - keepGoing = true; - } - if (commands.remove("-noinput")) { //$NON-NLS-1$ - allowInput = false; - } - arg = getArgument(commands, "-lib"); //$NON-NLS-1$ - if (arg != null) { - logMessage(currentProject, RemoteAntMessages.getString("InternalAntRunner.157"), Project.MSG_ERR); //$NON-NLS-1$ - return false; - } + if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$ + keepGoing = true; + } + if (commands.remove("-noinput")) { //$NON-NLS-1$ + allowInput = false; + } + arg = getArgument(commands, "-lib"); //$NON-NLS-1$ + if (arg != null) { + logMessage(currentProject, RemoteAntMessages.getString("InternalAntRunner.157"), Project.MSG_ERR); //$NON-NLS-1$ + return false; } arg = getArgument(commands, "-find"); //$NON-NLS-1$ @@ -1071,10 +865,6 @@ private boolean processProperties(List commands) { // MULTIPLE property files are allowed String arg = getArgument(commands, "-propertyfile"); //$NON-NLS-1$ while (arg != null) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - fEarlyErrorMessage = RemoteAntMessages.getString("InternalAntRunner.Specifying_property_files_is_a_Ant_1.5.*_feature._Please_update_your_Ant_classpath._6"); //$NON-NLS-1$ - break; - } if (arg.length() == 0) { fEarlyErrorMessage = RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_property_filename_when_using_the_-propertyfile_argument_3"); //$NON-NLS-1$ exceptionToBeThrown = true; @@ -1313,9 +1103,6 @@ private void loadPropertyFiles() { * @exception BuildException if a specified InputHandler implementation could not be loaded. */ private void addInputHandler(Project project) { - if (!isVersionCompatible("1.5")) { //$NON-NLS-1$ - return; - } InputHandlerSetter setter = new InputHandlerSetter(); setter.setInputHandler(project, inputHandlerClassname); }