Merged fix for 21595 into R2_0_1 branch.
diff --git a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java
index 8d5ff74..c9312e0 100644
--- a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java
+++ b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java
@@ -234,6 +234,7 @@
run.invoke(runner, new Object[] {argArray});
return null;
}
+
/**
* Returns the build file target information.
*
@@ -278,48 +279,4 @@
String message = (e.getMessage() == null) ? Policy.bind("error.buildFailed") : e.getMessage(); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, PI_ANTCORE, ERROR_RUNNING_SCRIPT, message, e));
}
-}/**
- * Returns the build file target information.
- *
- * @return an array containing the target information
- *
- * @see TargetInfo
- */
-public TargetInfo[] getAvailableTargets() throws CoreException {
- try {
- ClassLoader loader = getClassLoader();
- Class classInternalAntRunner = loader.loadClass("org.eclipse.ant.internal.core.ant.InternalAntRunner"); //$NON-NLS-1$
- Object runner = classInternalAntRunner.newInstance();
- // set build file
- Method setBuildFileLocation = classInternalAntRunner.getMethod("setBuildFileLocation", new Class[] {String.class}); //$NON-NLS-1$
- setBuildFileLocation.invoke(runner, new Object[] {buildFileLocation});
- // get the info for each targets
- Method getTargets = classInternalAntRunner.getMethod("getTargets", null); //$NON-NLS-1$
- Object results = getTargets.invoke(runner, null);
- // collect the info into target objects
- String[][] infos = (String[][]) results;
- if (infos.length < 2)
- return new TargetInfo[0];
- // The last info is the name of the default target or null if none
- int count = infos.length - 1;
- String defaultName = infos[count][0];
- TargetInfo[] targets = new TargetInfo[count];
- for (int i = 0; i < count; i++) {
- String[] info = infos[i];
- boolean isDefault = info[0].equals(defaultName);
- targets[i] = new TargetInfo(info[0], info[1], isDefault);
- }
- return targets;
- } catch (NoClassDefFoundError e) {
- throw new CoreException(new Status(IStatus.ERROR, PI_ANTCORE, ERROR_RUNNING_SCRIPT, Policy.bind("error.incorrectClasspath"), e)); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- throw new CoreException(new Status(IStatus.ERROR, PI_ANTCORE, ERROR_RUNNING_SCRIPT, Policy.bind("error.incorrectClasspath"), e)); //$NON-NLS-1$
- } catch (InvocationTargetException e) {
- Throwable realException = e.getTargetException();
- String message = (realException.getMessage() == null) ? Policy.bind("error.buildFailed") : realException.getMessage(); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, PI_ANTCORE, ERROR_RUNNING_SCRIPT, message, realException));
- } catch (Exception e) {
- String message = (e.getMessage() == null) ? Policy.bind("error.buildFailed") : e.getMessage(); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, PI_ANTCORE, ERROR_RUNNING_SCRIPT, message, e));
- }
}}
\ No newline at end of file
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 02b5404..e6d21c7 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
@@ -801,34 +801,4 @@
}
infos[i][0] = defaultName;
return infos;
-}
-/**
- * Gets all the target information from the build script.
- * Returns a two dimension array. Each row represents a
- * target, where the first column is the name and the
- * second column is the description. The last row is
- * special and represents the name of the default target.
- * This default target name is in the first column, the
- * second column is null. Note, the default name can be
- * null.
- */
-public String[][] getTargets() {
- // create a project and initialize it
- Project antProject = new Project();
- antProject.init();
- antProject.setProperty("ant.file", getBuildFileLocation()); //$NON-NLS-1$
- parseScript(antProject);
- String defaultName = antProject.getDefaultTarget();
- Collection targets = antProject.getTargets().values();
- String[][] infos = new String[targets.size() + 1][2];
- Iterator enum = targets.iterator();
- int i = 0;
- while (enum.hasNext()) {
- Target target = (Target) enum.next();
- infos[i][0] = target.getName();
- infos[i][1] = target.getDescription();
- i++;
- }
- infos[i][0] = defaultName;
- return infos;
}}
\ No newline at end of file