org.eclipse.ant.core_3.2.401.v20121204-162022

nClassLoaders.add(loader);
    }
  }
  
  public URL[] getExtraClasspathURLs()
  {
    URL[] urls = new URL[extraClasspathURLs.size()];
    for (int i = 0; i < extraClasspathURLs.size(); i++)
    {
      IAntClasspathEntry entry = (IAntClasspathEntry)extraClasspathURLs.get(i);
      urls[i] = entry.getEntryURL();
    }
    return urls;
  }
  
  public URL[] getRemoteExtraClasspathURLs()
  {
    List urls = new ArrayList(extraClasspathURLs.size());
    for (int i = 0; i < extraClasspathURLs.size(); i++)
    {
      IAntClasspathEntry entry = (IAntClasspathEntry)extraClasspathURLs.get(i);
      if (!entry.isEclipseRuntimeRequired()) {
        urls.add(entry.getEntryURL());
      }
    }
    return (URL[])urls.toArray(new URL[urls.size()]);
  }
  
  public URL[] getURLs()
  {
    List result = new ArrayList(60);
    if (antHomeEntries != null) {
      addEntryURLs(result, antHomeEntries);
    }
    if ((additionalEntries != null) && (additionalEntries.length > 0)) {
      addEntryURLs(result, additionalEntries);
    }
    for (int i = 0; i < extraClasspathURLs.size(); i++)
    {
      IAntClasspathEntry entry = (IAntClasspathEntry)extraClasspathURLs.get(i);
      URL url = entry.getEntryURL();
      if (url != null) {
        result.add(url);
      }
    }
    return (URL[])result.toArray(new URL[result.size()]);
  }
  
  private void addEntryURLs(List result, IAntClasspathEntry[] entries)
  {
    for (int i = 0; i < entries.length; i++)
    {
      IAntClasspathEntry entry = entries[i];
      URL url = entry.getEntryURL();
      if (url != null) {
        result.add(url);
      }
    }
  }
  
  protected ClassLoader[] getPluginClassLoaders()
  {
    if (orderedPluginClassLoaders == null)
    {
      Iterator classLoaders = pluginClassLoaders.iterator();
      Map idToLoader = new HashMap(pluginClassLoaders.size());
      List bundles = new ArrayList(pluginClassLoaders.size());
      while (classLoaders.hasNext())
      {
        WrappedClassLoader loader = (WrappedClassLoader)classLoaders.next();
        idToLoader.put(bundle.getSymbolicName(), loader);
        bundles.add(Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId()));
      }
      List descriptions = computePrerequisiteOrder(bundles);
      List loaders = new ArrayList(descriptions.size());
      for (Iterator iter = descriptions.iterator(); iter.hasNext();)
      {
        String id = ((BundleDescription)iter.next()).getSymbolicName();
        loaders.add(idToLoader.get(id));
      }
      orderedPluginClassLoaders = ((WrappedClassLoader[])loaders.toArray(new WrappedClassLoader[loaders.size()]));
    }
    return orderedPluginClassLoaders;
  }
  
  private List computePrerequisiteOrder(List plugins)
  {
    List prereqs = new ArrayList(plugins.size());
    List fragments = new ArrayList();
    for (Iterator iter = plugins.iterator(); iter.hasNext();)
    {
      BundleDescription current = (BundleDescription)iter.next();
      if (current.getHost() != null)
      {
        fragments.add(current);
      }
      else
      {
        boolean found = false;
        
        BundleDescription[] prereqList = getDependentBundles(current);
        for (int j = 0; j < prereqList.length; j++) {
          if (plugins.contains(prereqList[j]))
          {
            found = true;
            prereqs.add(new Relation(current, prereqList[j]));
          }
        }
        if (!found) {
          prereqs.add(new Relation(current, null));
        }
      }
    }
    BundleDescription[] prereqList;
    int j;
    for (Iterator iter = fragments.iterator(); iter.hasNext(); j < prereqList.length)
    {
      BundleDescription current = (BundleDescription)iter.next();
      if (plugins.contains(current.getHost().getBundle())) {
        prereqs.add(new Relation(current, current.getHost().getSupplier()));
      } else {
        AntCorePlugin.getPlugin().getLog().log(new Status(4, "org.eclipse.ant.core", 2, NLS.bind(InternalCoreAntMessages.AntCorePreferences_1, new String[] { current.getSymbolicName() }), null));
      }
      prereqList = getDependentBundles(current);
      j = 0; continue;
      if (plugins.contains(prereqList[j])) {
        prereqs.add(new Relation(current, prereqList[j]));
      }
      j++;
    }
    return computeNodeOrder(prereqs);
  }
  
  private BundleDescription[] getDependentBundles(BundleDescription root)
  {
    BundleDescription[] imported = getImportedBundles(root);
    BundleDescription[] required = getRequiredBundles(root);
    BundleDescription[] dependents = new BundleDescription[imported.length + required.length];
    System.arraycopy(imported, 0, dependents, 0, imported.length);
    System.arraycopy(required, 0, dependents, imported.length, required.length);
    return dependents;
  }
  
  private BundleDescription[] getRequiredBundles(BundleDescription root)
  {
    if (root == null) {
      return new BundleDescription[0];
    }
    return root.getResolvedRequires();
  }
  
  private BundleDescription[] getImportedBundles(BundleDescription root)
  {
    if (root == null) {
      return new BundleDescription[0];
    }
    ExportPackageDescription[] packages = root.getResolvedImports();
    ArrayList resolvedImports = new ArrayList(packages.length);
    for (int i = 0; i < packages.length; i++) {
      if ((!root.getLocation().equals(packages[i].getExporter().getLocation())) && (!resolvedImports.contains(packages[i].getExporter()))) {
        resolvedImports.add(packages[i].getExporter());
      }
    }
    return (BundleDescription[])resolvedImports.toArray(new BundleDescription[resolvedImports.size()]);
  }
  
  private void removeArcs(List edges, List roots, Map counts)
  {
    int i;
    for (Iterator j = roots.iterator(); j.hasNext(); i < edges.size())
    {
      Object root = j.next();
      i = 0; continue;
      if (root.equals(getto))
      {
        Object input = getfrom;
        Integer count = (Integer)counts.get(input);
        if (count != null) {
          counts.put(input, new Integer(count.intValue() - 1));
        }
      }
      i++;
    }
  }
  
  private List computeNodeOrder(List edges)
  {
    Map counts = computeCounts(edges);
    List nodes = new ArrayList(counts.size());
    while (!counts.isEmpty())
    {
      List roots = findRootNodes(counts);
      if (roots.isEmpty()) {
        break;
      }
      for (Iterator i = roots.iterator(); i.hasNext();) {
        counts.remove(i.next());
      }
      nodes.addAll(roots);
      removeArcs(edges, roots, counts);
    }
    return nodes;
  }
  
  private Map computeCounts(List mappings)
  {
    Map counts = new HashMap(5);
    for (int i = 0; i < mappings.size(); i++)
    {
      Object from = getfrom;
      Integer fromCount = (Integer)counts.get(from);
      Object to = getto;
      if (to == null)
      {
        counts.put(from, new Integer(0));
      }
      else
      {
        if ((Integer)counts.get(to) == null) {
          counts.put(to, new Integer(0));
        }
        fromCount = fromCount == null ? new Integer(1) : new Integer(fromCount.intValue() + 1);
        counts.put(from, fromCount);
      }
    }
    return counts;
  }
  
  private List findRootNodes(Map counts)
  {
    List result = new ArrayList(5);
    for (Iterator i = counts.keySet().iterator(); i.hasNext();)
    {
      Object node = i.next();
      int count = ((Integer)counts.get(node)).intValue();
      if (count == 0) {
        result.add(node);
      }
    }
    return result;
  }
  
  private void initializePluginClassLoaders()
  {
    pluginClassLoaders = new ArrayList(10);
    
    pluginClassLoaders.add(new WrappedClassLoader(AntCorePlugin.getPlugin().getBundle()));
  }
  
  public List getTasks()
  {
    List result = new ArrayList(10);
    if ((defaultTasks != null) && (!defaultTasks.isEmpty())) {
      result.addAll(defaultTasks);
    }
    if ((customTasks != null) && (customTasks.length != 0)) {
      result.addAll(Arrays.asList(customTasks));
    }
    return result;
  }
  
  public List getRemoteTasks()
  {
    List result = new ArrayList(10);
    if ((defaultTasks != null) && (!defaultTasks.isEmpty()))
    {
      Iterator iter = defaultTasks.iterator();
      while (iter.hasNext())
      {
        Task task = (Task)iter.next();
        if (!task.isEclipseRuntimeRequired()) {
          result.add(task);
        }
      }
    }
    if ((customTasks != null) && (customTasks.length != 0)) {
      result.addAll(Arrays.asList(customTasks));
    }
    return result;
  }
  
  public Task[] getCustomTasks()
  {
    return customTasks;
  }
  
  public Type[] getCustomTypes()
  {
    return customTypes;
  }
  
  public Property[] getCustomProperties()
  {
    return customProperties;
  }
  
  public List getProperties()
  {
    List result = new ArrayList(10);
    if ((defaultProperties != null) && (!defaultProperties.isEmpty())) {
      result.addAll(defaultProperties);
    }
    if ((customProperties != null) && (customProperties.length != 0)) {
      result.addAll(Arrays.asList(customProperties));
    }
    return result;
  }
  
  public List getRemoteAntProperties()
  {
    List result = new ArrayList(10);
    if ((defaultProperties != null) && (!defaultProperties.isEmpty()))
    {
      Iterator iter = defaultProperties.iterator();
      while (iter.hasNext())
      {
        Property property = (Property)iter.next();
        if (!property.isEclipseRuntimeRequired()) {
          result.add(property);
        }
      }
    }
    if ((customProperties != null) && (customProperties.length != 0)) {
      result.addAll(Arrays.asList(customProperties));
    }
    return result;
  }
  
  public String[] getCustomPropertyFiles(boolean performStringSubstition)
  {
    if ((!performStringSubstition) || (customPropertyFiles == null) || (customPropertyFiles.length == 0)) {
      return customPropertyFiles;
    }
    List files = new ArrayList(customPropertyFiles.length);
    for (int i = 0; i < customPropertyFiles.length; i++)
    {
      String filename = customPropertyFiles[i];
      try
      {
        filename = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(filename);
        files.add(filename);
      }
      catch (CoreException localCoreException)
      {
        files.add(filename);
      }
    }
    return (String[])files.toArray(new String[files.size()]);
  }
  
  public String[] getCustomPropertyFiles()
  {
    return getCustomPropertyFiles(true);
  }
  
  /**
   * @deprecated
   */
  public URL[] getCustomURLs()
  {
    URL[] urls = new URL[additionalEntries.length];
    for (int i = 0; i < additionalEntries.length; i++)
    {
      URL url = additionalEntries[i].getEntryURL();
      if (url != null) {
        urls[i] = url;
      }
    }
    return urls;
  }
  
  public void setCustomTasks(Task[] tasks)
  {
    oldCustomTasks = customTasks;
    customTasks = tasks;
  }
  
  public void setCustomTypes(Type[] types)
  {
    oldCustomTypes = customTypes;
    customTypes = types;
  }
  
  /**
   * @deprecated
   */
  public void setCustomURLs(URL[] urls)
  {
    additionalEntries = new IAntClasspathEntry[urls.length];
    for (int i = 0; i < urls.length; i++)
    {
      URL url = urls[i];
      IAntClasspathEntry entry = new AntClasspathEntry(url);
      additionalEntries[i] = entry;
    }
  }
  
  /**
   * @deprecated
   */
  public void setAntURLs(URL[] urls)
  {
    antHomeEntries = new IAntClasspathEntry[urls.length];
    for (int i = 0; i < urls.length; i++)
    {
      URL url = urls[i];
      IAntClasspathEntry entry = new AntClasspathEntry(url);
      antHomeEntries[i] = entry;
    }
  }
  
  public void setCustomPropertyFiles(String[] paths)
  {
    customPropertyFiles = paths;
  }
  
  public void setCustomProperties(Property[] properties)
  {
    oldCustomProperties = customProperties;
    customProperties = properties;
  }
  
  public List getTypes()
  {
    List result = new ArrayList(10);
    if ((defaultTypes != null) && (!defaultTypes.isEmpty())) {
      result.addAll(defaultTypes);
    }
    if ((customTypes != null) && (customTypes.length != 0)) {
      result.addAll(Arrays.asList(customTypes));
    }
    return result;
  }
  
  public List getRemoteTypes()
  {
    List result = new ArrayList(10);
    if ((defaultTypes != null) && (!defaultTypes.isEmpty()))
    {
      Iterator iter = defaultTypes.iterator();
      while (iter.hasNext())
      {
        Type type = (Type)iter.next();
        if (!type.isEclipseRuntimeRequired()) {
          result.add(type);
        }
      }
    }
    if ((customTypes != null) && (customTypes.length != 0)) {
      result.addAll(Arrays.asList(customTypes));
    }
    return result;
  }
  
  public List getDefaultTypes()
  {
    List result = new ArrayList(10);
    if ((defaultTypes != null) && (!defaultTypes.isEmpty())) {
      result.addAll(defaultTypes);
    }
    return result;
  }
  
  public List getDefaultTasks()
  {
    List result = new ArrayList(10);
    if ((defaultTasks != null) && (!defaultTasks.isEmpty())) {
      result.addAll(defaultTasks);
    }
    return result;
  }
  
  public List getDefaultProperties()
  {
    List result = new ArrayList(10);
    if ((defaultProperties != null) && (!defaultProperties.isEmpty())) {
      result.addAll(defaultProperties);
    }
    return result;
  }
  
  protected String[] getArrayFromString(String list)
  {
    String separator = ",";
    if ((list == null) || (list.trim().equals(""))) {
      return new String[0];
    }
    ArrayList result = new ArrayList();
    for (StringTokenizer tokens = new StringTokenizer(list, separator); tokens.hasMoreTokens();)
    {
      String token = tokens.nextToken().trim();
      if (!token.equals("")) {
        result.add(token);
      }
    }
    return (String[])result.toArray(new String[result.size()]);
  }
  
  public void updatePluginPreferences()
  {
    Preferences prefs = AntCorePlugin.getPlugin().getPluginPreferences();
    prefs.removePropertyChangeListener(this);
    updateTasks(prefs);
    updateTypes(prefs);
    updateAntHomeEntries(prefs);
    updateAdditionalEntries(prefs);
    updateProperties(prefs);
    updatePropertyFiles(prefs);
    boolean classpathChanged = AntCorePlugin.getPlugin().getPluginPreferences().needsSaving();
    AntCorePlugin.getPlugin().savePluginPreferences();
    if (classpathChanged) {
      prefs.setValue("classpath_changed", true);
    }
    prefs.setValue("classpath_changed", false);
    prefs.addPropertyChangeListener(this);
  }
  
  protected void updateTasks(Preferences prefs)
  {
    if (oldCustomTasks != null)
    {
      for (int i = 0; i < oldCustomTasks.length; i++)
      {
        Task oldTask = oldCustomTasks[i];
        prefs.setToDefault("task." + oldTask.getTaskName());
      }
      oldCustomTasks = null;
    }
    if (customTasks.length == 0)
    {
      prefs.setValue("tasks", "");
      return;
    }
    StringBuffer tasks = new StringBuffer();
    for (int i = 0; i < customTasks.length; i++)
    {
      tasks.append(customTasks[i].getTaskName());
      tasks.append(',');
      prefs.setValue("task." + customTasks[i].getTaskName(), customTasks[i].getClassName() + "," + customTasks[i].getLibraryEntry().getLabel());
    }
    prefs.setValue("tasks", tasks.toString());
  }
  
  protected void updateTypes(Preferences prefs)
  {
    if (oldCustomTypes != null)
    {
      for (int i = 0; i < oldCustomTypes.length; i++)
      {
        Type oldType = oldCustomTypes[i];
        prefs.setToDefault("type." + oldType.getTypeName());
      }
      oldCustomTypes = null;
    }
    if (customTypes.length == 0)
    {
      prefs.setValue("types", "");
      return;
    }
    StringBuffer types = new StringBuffer();
    for (int i = 0; i < customTypes.length; i++)
    {
      types.append(customTypes[i].getTypeName());
      types.append(',');
      prefs.setValue("type." + customTypes[i].getTypeName(), customTypes[i].getClassName() + "," + customTypes[i].getLibraryEntry().getLabel());
    }
    prefs.setValue("types", types.toString());
  }
  
  protected void updateProperties(Preferences prefs)
  {
    if (oldCustomProperties != null)
    {
      for (int i = 0; i < oldCustomProperties.length; i++)
      {
        Property oldProperty = oldCustomProperties[i];
        prefs.setToDefault("property." + oldProperty.getName());
      }
      oldCustomProperties = null;
    }
    if (customProperties.length == 0)
    {
      prefs.setValue("properties", "");
      return;
    }
    StringBuffer properties = new StringBuffer();
    for (int i = 0; i < customProperties.length; i++)
    {
      properties.append(customProperties[i].getName());
      properties.append(',');
      prefs.setValue("property." + customProperties[i].getName(), customProperties[i].getValue(false));
    }
    prefs.setValue("properties", properties.toString());
  }
  
  protected void updateAdditionalEntries(Preferences prefs)
  {
    prefs.setValue("urls", "");
    String serialized = "";
    IAntClasspathEntry toolsJarEntry = getToolsJarEntry();
    List userLibs = getUserLibraries();
    if (userLibs == null) {
      userLibs = new ArrayList();
    }
    if (toolsJarEntry != null) {
      userLibs.add(toolsJarEntry);
    }
    boolean changed = true;
    if (additionalEntries.length == userLibs.size())
    {
      changed = false;
      for (int i = 0; i < additionalEntries.length; i++) {
        if (!additionalEntries[i].equals(userLibs.get(i)))
        {
          changed = true;
          break;
        }
      }
    }
    if (changed)
    {
      StringBuffer entries = new StringBuffer();
      for (int i = 0; i < additionalEntries.length; i++)
      {
        entries.append(additionalEntries[i].getLabel());
        entries.append(',');
      }
      serialized = entries.toString();
    }
    prefs.setValue("additional_entries", serialized);
    
    String prefAntHome = "";
    if ((antHome != null) && (!antHome.equals(getDefaultAntHome()))) {
      prefAntHome = antHome;
    }
    prefs.setValue("ant_home", prefAntHome);
  }
  
  protected void updateAntHomeEntries(Preferences prefs)
  {
    prefs.setValue("ant_urls", "");
    
    IAntClasspathEntry[] defaultEntries = getDefaultAntHomeEntries();
    boolean dflt = false;
    if (defaultEntries.length == antHomeEntries.length)
    {
      dflt = true;
      for (int i = 0; i < antHomeEntries.length; i++) {
        if (!antHomeEntries[i].equals(defaultEntries[i]))
        {
          dflt = false;
          break;
        }
      }
    }
    if (dflt)
    {
      prefs.setValue("ant_home_entries", "");
      return;
    }
    StringBuffer entries = new StringBuffer();
    for (int i = 0; i < antHomeEntries.length; i++)
    {
      entries.append(antHomeEntries[i].getLabel());
      entries.append(',');
    }
    prefs.setValue("ant_home_entries", entries.toString());
  }
  
  protected void updatePropertyFiles(Preferences prefs)
  {
    StringBuffer files = new StringBuffer();
    for (int i = 0; i < customPropertyFiles.length; i++)
    {
      files.append(customPropertyFiles[i]);
      files.append(',');
    }
    prefs.setValue("propertyfiles", files.toString());
  }
  
  public void setAntHome(String antHome)
  {
    this.antHome = antHome;
  }
  
  public String getAntHome()
  {
    return antHome;
  }
  
  public IAntClasspathEntry[] getAntHomeClasspathEntries()
  {
    return antHomeEntries;
  }
  
  public IAntClasspathEntry[] getAdditionalClasspathEntries()
  {
    return additionalEntries;
  }
  
  public void setAntHomeClasspathEntries(IAntClasspathEntry[] entries)
  {
    antHomeEntries = entries;
  }
  
  public void setAdditionalClasspathEntries(IAntClasspathEntry[] entries)
  {
    additionalEntries = entries;
  }
  
  public URL[] getRemoteAntURLs()
  {
    List result = new ArrayList(40);
    if (antHomeEntries != null) {
      for (int i = 0; i < antHomeEntries.length; i++)
      {
        IAntClasspathEntry entry = antHomeEntries[i];
        result.add(entry.getEntryURL());
      }
    }
    if ((additionalEntries != null) && (additionalEntries.length > 0)) {
      for (int i = 0; i < additionalEntries.length; i++)
      {
        IAntClasspathEntry entry = additionalEntries[i];
        result.add(entry.getEntryURL());
      }
    }
    if (extraClasspathURLs != null) {
      for (int i = 0; i < extraClasspathURLs.size(); i++)
      {
        IAntClasspathEntry entry = (IAntClasspathEntry)extraClasspathURLs.get(i);
        if (!entry.isEclipseRuntimeRequired()) {
          result.add(entry.getEntryURL());
        }
      }
    }
    return (URL[])result.toArray(new URL[result.size()]);
  }
  
  public IAntClasspathEntry[] getContributedClasspathEntries()
  {
    return (IAntClasspathEntry[])extraClasspathURLs.toArray(new IAntClasspathEntry[extraClasspathURLs.size()]);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ant.core.AntCorePreferences
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ant.core;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.ant.internal.core.AntClassLoader;
import org.eclipse.ant.internal.core.InternalCoreAntMessages;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.util.NLS;

public class AntRunner
  implements IApplication
{
  private static boolean buildRunning = false;
  protected String buildFileLocation = "build.xml";
  protected List buildListeners;
  protected String[] targets;
  protected Map userProperties;
  protected int messageOutputLevel = 2;
  protected String buildLoggerClassName;
  protected String inputHandlerClassName;
  protected String[] arguments;
  protected String[] propertyFiles;
  protected URL[] customClasspath;
  protected String antHome;
  private IProgressMonitor progressMonitor = null;
  static Class class$2;
  static Class class$3;
  static Class class$4;
  static Class class$7;
  
  public void setBuildFileLocation(String buildFileLocation)
  {
    if (buildFileLocation == null) {
      this.buildFileLocation = "build.xml";
    } else {
      this.buildFileLocation = buildFileLocation;
    }
  }
  
  public void setMessageOutputLevel(int level)
  {
    messageOutputLevel = level;
  }
  
  public void setArguments(String arguments)
  {
    this.arguments = getArray(arguments);
  }
  
  private String[] getArray(String args)
  {
    StringBuffer sb = new StringBuffer();
    boolean waitingForQuote = false;
    ArrayList result = new ArrayList();
    for (StringTokenizer tokens = new StringTokenizer(args, ", \"", true); tokens.hasMoreTokens();)
    {
      String token = tokens.nextToken();
      if (waitingForQuote)
      {
        if (token.equals("\""))
        {
          result.add(sb.toString());
          sb.setLength(0);
          waitingForQuote = false;
        }
        else
        {
          sb.append(token);
        }
      }
      else if (token.equals("\""))
      {
        if (result.size() > 0)
        {
          int index = result.size() - 1;
          String last = (String)result.get(index);
          if (last.charAt(last.length() - 1) == '=')
          {
            result.remove(index);
            sb.append(last);
          }
        }
        waitingForQuote = true;
      }
      else if ((!token.equals(",")) && (!token.equals(" ")))
      {
        result.add(token);
      }
    }
    return (String[])result.toArray(new String[result.size()]);
  }
  
  public void setArguments(String[] arguments)
  {
    this.arguments = arguments;
  }
  
  public void setExecutionTargets(String[] executionTargets)
  {
    targets = executionTargets;
  }
  
  public void addBuildListener(String className)
  {
    if (className == null) {
      return;
    }
    if (buildListeners == null) {
      buildListeners = new ArrayList(5);
    }
    buildListeners.add(className);
  }
  
  public void addBuildLogger(String className)
  {
    buildLoggerClassName = className;
  }
  
  public void addUserProperties(Map properties)
  {
    if (userProperties == null) {
      userProperties = new HashMap(properties);
    } else {
      userProperties.putAll(properties);
    }
  }
  
  public synchronized TargetInfo[] getAvailableTargets()
    throws CoreException
  {
    Class classInternalAntRunner = null;
    Object runner = null;
    ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
    try
    {
      classInternalAntRunner = getInternalAntRunner();
      runner = classInternalAntRunner.newInstance();
      
      basicConfigure(classInternalAntRunner, runner);
      
      Method getTargets = classInternalAntRunner.getMethod("getTargets", null);
      Object results = getTargets.invoke(runner, null);
      
      Method getDefault = classInternalAntRunner.getMethod("getDefaultTarget", null);
      String defaultName = (String)getDefault.invoke(runner, null);
      
      List infos = (List)results;
      
      ProjectInfo project = new ProjectInfo((String)infos.remove(0), (String)infos.remove(0));
      int i = 0;
      Iterator iter = infos.iterator();
      TargetInfo[] targetInfo = new TargetInfo[infos.size()];
      while (iter.hasNext())
      {
        List info = (List)iter.next();
        targetInfo[(i++)] = new TargetInfo(project, (String)info.get(0), (String)info.get(1), (String[])info.get(2), info.get(0).equals(defaultName));
      }
      return targetInfo;
    }
    catch (NoClassDefFoundError e)
    {
      problemLoadingClass(e);
      
      return new TargetInfo[0];
    }
    catch (ClassNotFoundException e)
    {
      problemLoadingClass(e);
      
      return new TargetInfo[0];
    }
    catch (InvocationTargetException e)
    {
      TargetInfo[] arrayOfTargetInfo1;
      handleInvocationTargetException(runner, classInternalAntRunner, e);
      
      return new TargetInfo[0];
    }
    catch (Exception e)
    {
      String message = e.getMessage() == null ? InternalCoreAntMessages.AntRunner_Build_Failed__3 : e.getMessage();
      throw new CoreException(new Status(4, "org.eclipse.ant.core", 1, message, e));
    }
    finally
    {
      Thread.currentThread().setContextClassLoader(originalClassLoader);
    }
  }
  
  private void basicConfigure(Class classInternalAntRunner, Object runner)
    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
  {
    Method setBuildFileLocation = classInternalAntRunner.getMethod("setBuildFileLocation", new Class[] { String.class });
    setBuildFileLocation.invoke(runner, new Object[] { buildFileLocation });
    if (antHome != null)
    {
      Method setAntHome = classInternalAntRunner.getMethod("setAntHome", new Class[] { String.class });
      setAntHome.invoke(runner, new Object[] { antHome });
    }
    setProperties(runner, classInternalAntRunner);
    if ((arguments != null) && (arguments.length > 0))
    {
      Method setArguments = classInternalAntRunner.getMethod("setArguments", new Class[] { String[].class });
      setArguments.invoke(runner, new Object[] { arguments });
    }
  }
  
  /* Error */
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    // Byte code:
    //   0: getstatic 448	org/eclipse/ant/core/AntRunner:buildRunning	Z
    //   3: ifeq +43 -> 46
    //   6: new 283	org/eclipse/core/runtime/Status
    //   9: dup
    //   10: iconst_4
    //   11: ldc_w 233
    //   14: iconst_1
    //   15: getstatic 469	org/eclipse/ant/internal/core/InternalCoreAntMessages:AntRunner_Already_in_progess	Ljava/lang/String;
    //   18: iconst_1
    //   19: anewarray 256	java/lang/String
    //   22: dup
    //   23: iconst_0
    //   24: aload_0
    //   25: getfield 459	org/eclipse/ant/core/AntRunner:buildFileLocation	Ljava/lang/String;
    //   28: aastore
    //   29: invokestatic 531	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   32: aconst_null
    //   33: invokespecial 530	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   36: astore_2
    //   37: new 278	org/eclipse/core/runtime/CoreException
    //   40: dup
    //   41: aload_2
    //   42: invokespecial 528	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   45: athrow
    //   46: iconst_1
    //   47: putstatic 448	org/eclipse/ant/core/AntRunner:buildRunning	Z
    //   50: aconst_null
    //   51: astore_2
    //   52: aconst_null
    //   53: astore_3
    //   54: invokestatic 493	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   57: invokevirtual 491	java/lang/Thread:getContextClassLoader	()Ljava/lang/ClassLoader;
    //   60: astore 4
    //   62: aload_0
    //   63: invokespecial 516	org/eclipse/ant/core/AntRunner:getInternalAntRunner	()Ljava/lang/Class;
    //   66: astore_3
    //   67: aload_3
    //   68: invokevirtual 473	java/lang/Class:newInstance	()Ljava/lang/Object;
    //   71: astore_2
    //   72: aload_3
    //   73: ldc_w 239
    //   76: iconst_1
    //   77: anewarray 247	java/lang/Class
    //   80: dup
    //   81: iconst_0
    //   82: getstatic 449	org/eclipse/ant/core/AntRunner:class$0	Ljava/lang/Class;
    //   85: dup
    //   86: ifnonnull +29 -> 115
    //   89: pop
    //   90: ldc_w 229
    //   93: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   96: dup
    //   97: putstatic 449	org/eclipse/ant/core/AntRunner:class$0	Ljava/lang/Class;
    //   100: goto +15 -> 115
    //   103: new 253	java/lang/NoClassDefFoundError
    //   106: dup_x1
    //   107: swap
    //   108: invokevirtual 494	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   111: invokespecial 479	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   114: athrow
    //   115: aastore
    //   116: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   119: astore 5
    //   121: aload 5
    //   123: aload_2
    //   124: iconst_1
    //   125: anewarray 255	java/lang/Object
    //   128: dup
    //   129: iconst_0
    //   130: aload_0
    //   131: getfield 459	org/eclipse/ant/core/AntRunner:buildFileLocation	Ljava/lang/String;
    //   134: aastore
    //   135: invokevirtual 496	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   138: pop
    //   139: aload_0
    //   140: getfield 465	org/eclipse/ant/core/AntRunner:customClasspath	[Ljava/net/URL;
    //   143: ifnull +70 -> 213
    //   146: aload_3
    //   147: ldc_w 240
    //   150: iconst_1
    //   151: anewarray 247	java/lang/Class
    //   154: dup
    //   155: iconst_0
    //   156: getstatic 451	org/eclipse/ant/core/AntRunner:class$2	Ljava/lang/Class;
    //   159: dup
    //   160: ifnonnull +29 -> 189
    //   163: pop
    //   164: ldc_w 221
    //   167: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   170: dup
    //   171: putstatic 451	org/eclipse/ant/core/AntRunner:class$2	Ljava/lang/Class;
    //   174: goto +15 -> 189
    //   177: new 253	java/lang/NoClassDefFoundError
    //   180: dup_x1
    //   181: swap
    //   182: invokevirtual 494	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   185: invokespecial 479	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   188: athrow
    //   189: aastore
    //   190: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   193: astore 6
    //   195: aload 6
    //   197: aload_2
    //   198: iconst_1
    //   199: anewarray 255	java/lang/Object
    //   202: dup
    //   203: iconst_0
    //   204: aload_0
    //   205: getfield 465	org/eclipse/ant/core/AntRunner:customClasspath	[Ljava/net/URL;
    //   208: aastore
    //   209: invokevirtual 496	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   212: pop
    //   213: aload_0
    //   214: getfield 466	org/eclipse/ant/core/AntRunner:buildListeners	Ljava/util/List;
    //   217: ifnull +70 -> 287
    //   220: aload_3
    //   221: ldc_w 222
    //   224: iconst_1
    //   225: anewarray 247	java/lang/Class
    //   228: dup
    //   229: iconst_0
    //   230: getstatic 452	org/eclipse/ant/core/AntRunner:class$3	Ljava/lang/Class;
    //   233: dup
    //   234: ifnonnull +29 -> 263
    //   237: pop
    //   238: ldc_w 231
    //   241: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   244: dup
    //   245: putstatic 452	org/eclipse/ant/core/AntRunner:class$3	Ljava/lang/Class;
    //   248: goto +15 -> 263
    //   251: new 253	java/lang/NoClassDefFoundError
    //   254: dup_x1
    //   255: swap
    //   256: invokevirtual 494	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   259: invokespecial 479	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   262: athrow
    //   263: aastore
    //   264: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   267: astore 6
    //   269: aload 6
    //   271: aload_2
    //   272: iconst_1
    //   273: anewarray 255	java/lang/Object
    //   276: dup
    //   277: iconst_0
    //   278: aload_0
    //   279: getfield 466	org/eclipse/ant/core/AntRunner:buildListeners	Ljava/util/List;
    //   282: aastore
    //   283: invokevirtual 496	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   286: pop
    //   287: aload_0
    //   288: getfield 460	org/eclipse/ant/core/AntRunner:buildLoggerClassName	Ljava/lang/String;
    //   291: ifnonnull +10 -> 301
    //   294: aload_0
    //   295: ldc_w 218
    //   298: putfield 460	org/eclipse/ant/core/AntRunner:buildLoggerClassName	Ljava/lang/String;
    //   301: aload_3
    //   302: ldc_w 223
    //   305: iconst_1
    //   306: anewarray 247	java/lang/Class
    //   309: dup
    //   310: iconst_0
    //   311: getstatic 449	org/eclipse/ant/core/AntRunner:class$0	Ljava/lang/Class;
    //   314: dup
    //   315: ifnonnull +29 -> 344
    //   318: pop
    //   319: ldc_w 229
    //   322: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   325: dup
    //   326: putstatic 449	org/eclipse/ant/core/AntRunner:class$0	Ljava/lang/Class;
    //   329: goto +15 -> 344
    //   332: new 253	java/lang/NoClassDefFoundError
    //   335: dup_x1
    //   336: swap
    //   337: invokevirtual 494	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   340: invokespecial 479	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   343: athrow
    //   344: aastore
    //   345: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   348: astore 6
    //   350: aload 6
    //   352: aload_2
    //   353: iconst_1
    //   354: anewarray 255	java/lang/Object
    //   357: dup
    //   358: iconst_0
    //   359: aload_0
    //   360: getfield 460	org/eclipse/ant/core/AntRunner:buildLoggerClassName	Ljava/lang/String;
    //   363: aastore
    //   364: invokevirtual 496	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   367: pop
    //   368: aload_0
    //   369: getfield 461	org/eclipse/ant/core/AntRunner:inputHandlerClassName	Ljava/lang/String;
    //   372: ifnull +70 -> 442
    //   375: aload_3
    //   376: ldc_w 242
    //   379: iconst_1
    //   380: anewarray 247	java/lang/Class
    //   383: dup
    //   384: iconst_0
    //   385: getstatic 449	org/eclipse/ant/core/AntRunner:class$0	Ljava/lang/Class;
    //   388: dup
    //   389: ifnonnull +29 -> 418
    //   392: pop
    //   393: ldc_w 229
    //   396: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   399: dup
    //   400: putstatic 449	org/eclipse/ant/core/AntRunner:class$0	Ljava/lang/Class;
    //   403: goto +15 -> 418
    //   406: new 253	java/lang/NoClassDefFoundError
    //   409: dup_x1
    //   410: swap
    //   411: invokevirtual 494	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   414: invokespecial 479	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   417: athrow
    //   418: aastore
    //   419: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   422: astore 7
    //   424: aload 7
    //   426: aload_2
    //   427: iconst_1
    //   428: anewarray 255	java/lang/Object
    //   431: dup
    //   432: iconst_0
    //   433: aload_0
    //   434: getfield 461	org/eclipse/ant/core/AntRunner:inputHandlerClassName	Ljava/lang/String;
    //   437: aastore
    //   438: invokevirtual 496	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   441: pop
    //   442: aload_0
    //   443: aload_3
    //   444: aload_2
    //   445: invokespecial 521	org/eclipse/ant/core/AntRunner:basicConfigure	(Ljava/lang/Class;Ljava/lang/Object;)V
    //   448: aload_1
    //   449: ifnull +72 -> 521
    //   452: aload_0
    //   453: aload_1
    //   454: putfield 468	org/eclipse/ant/core/AntRunner:progressMonitor	Lorg/eclipse/core/runtime/IProgressMonitor;
    //   457: aload_3
    //   458: ldc_w 244
    //   461: iconst_1
    //   462: anewarray 247	java/lang/Class
    //   465: dup
    //   466: iconst_0
    //   467: getstatic 453	org/eclipse/ant/core/AntRunner:class$4	Ljava/lang/Class;
    //   470: dup
    //   471: ifnonnull +29 -> 500
    //   474: pop
    //   475: ldc_w 235
    //   478: invokestatic 474	java/lang/Class:forName	(Ljava/lang/String;)Ljava/lang/Class;
    //   481: dup
    //   482: putstatic 453	org/eclipse/ant/core/AntRunner:class$4	Ljava/lang/Class;
    //   485: goto +15 -> 500
    //   488: new 253	java/lang/NoClassDefFoundError
    //   491: dup_x1
    //   492: swap
    //   493: invokevirtual 494	java/lang/Throwable:getMessage	()Ljava/lang/String;
    //   496: invokespecial 479	java/lang/NoClassDefFoundError:<init>	(Ljava/lang/String;)V
    //   499: athrow
    //   500: aastore
    //   501: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   504: astore 7
    //   506: aload 7
    //   508: aload_2
    //   509: iconst_1
    //   510: anewarray 255	java/lang/Object
    //   513: dup
    //   514: iconst_0
    //   515: aload_1
    //   516: aastore
    //   517: invokevirtual 496	java/lang/reflect/Method:invoke	(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
    //   520: pop
    //   521: aload_0
    //   522: getfield 447	org/eclipse/ant/core/AntRunner:messageOutputLevel	I
    //   525: iconst_2
    //   526: if_icmpeq +47 -> 573
    //   529: aload_3
    //   530: ldc_w 243
    //   533: iconst_1
    //   534: anewarray 247	java/lang/Class
    //   537: dup
    //   538: iconst_0
    //   539: getstatic 446	java/lang/Integer:TYPE	Ljava/lang/Class;
    //   542: aastore
    //   543: invokevirtual 475	java/lang/Class:getMethod	(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
    //   546: astore 7
    //   548: aload 7
    //   550: aload_2
    //   551: iconst_1
    //   552: anewarray 255	java/lang/Object
    //   555: dup
    //   556: iconst_0
    //   557: new 252	java/lang/Integer
    //   560: dup
    //   561: aload_0
    //   562: getfiel
1 2 3 4

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd