pdebuild

16:50:55.029 INFO  jd.cli.Main - Decompiling pdebuild.jar
package org.eclipse.pde.build;

public abstract interface Constants
{
  public static final String FEATURE_FILENAME_DESCRIPTOR = "feature.xml";
  public static final String FRAGMENT_FILENAME_DESCRIPTOR = "fragment.xml";
  public static final String PLUGIN_FILENAME_DESCRIPTOR = "plugin.xml";
  public static final String BUNDLE_FILENAME_DESCRIPTOR = "META-INF/MANIFEST.MF";
  public static final String KEY_SOURCE_REFERENCES = "sourceReferences";
}

/* Location:
 * Qualified Name:     org.eclipse.pde.build.Constants
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.build;

import java.util.List;
import java.util.Map;

public abstract interface IAntScript
{
  public abstract void print(String paramString);
  
  public abstract void printComment(String paramString);
  
  public abstract void println(String paramString);
  
  public abstract void println();
  
  public abstract void printAntCallTask(String paramString, boolean paramBoolean, Map paramMap);
  
  public abstract void printAttribute(String paramString1, String paramString2, boolean paramBoolean);
  
  public abstract void printStartTag(String paramString);
  
  public abstract void printStartTag(String paramString, Map paramMap);
  
  public abstract void printEndTag(String paramString);
  
  public abstract void printElement(String paramString, Map paramMap);
  
  public abstract void printTabs();
  
  public abstract void incrementIdent();
  
  public abstract void decrementIdent();
  
  public abstract void printTargetDeclaration(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5);
  
  public abstract void printTargetEnd();
  
  public abstract void printEchoTask(String paramString1, String paramString2, String paramString3);
  
  public abstract void printMacroDef(String paramString, List paramList);
  
  public abstract void printEndMacroDef();
}

/* Location:
 * Qualified Name:     org.eclipse.pde.build.IAntScript
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.build;

import java.util.Map;
import java.util.Properties;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;

public abstract interface IFetchFactory
{
  public static final String KEY_ELEMENT_NAME = "element";
  public static final String KEY_ELEMENT_TYPE = "type";
  public static final String KEY_ELEMENT_TAG = "tag";
  public static final String ELEMENT_TYPE_BUNDLE = "bundle";
  public static final String ELEMENT_TYPE_FEATURE = "feature";
  public static final String ELEMENT_TYPE_FRAGMENT = "fragment";
  public static final String ELEMENT_TYPE_PLUGIN = "plugin";
  
  public abstract void parseMapFileEntry(String paramString, Properties paramProperties, Map paramMap)
    throws CoreException;
  
  public abstract void generateRetrieveElementCall(Map paramMap, IPath paramIPath, IAntScript paramIAntScript);
  
  public abstract void generateRetrieveFilesCall(Map paramMap, IPath paramIPath, String[] paramArrayOfString, IAntScript paramIAntScript);
  
  public abstract void addTargets(IAntScript paramIAntScript);
}

/* Location:
 * Qualified Name:     org.eclipse.pde.build.IFetchFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.build;

import java.io.File;
import java.io.FilenameFilter;

class AbstractScriptGenerator$1
  implements FilenameFilter
{
  public boolean accept(File dir, String name)
  {
    return (name.startsWith("content.")) || (name.startsWith("compositeContent.")) || (name.endsWith(".profile")) || (name.endsWith(".profile.gz"));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.build.AbstractScriptGenerator.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.build;

import java.io.File;
import java.io.FilenameFilter;

class AbstractScriptGenerator$2
  implements FilenameFilter
{
  public boolean accept(File dir, String name)
  {
    return (name.startsWith("artifacts.")) || (name.startsWith("compositeArtifacts."));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.build.AbstractScriptGenerator.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.build;

import java.util.Properties;

public class AbstractScriptGenerator$MissingProperties
  extends Properties
{
  private static final long serialVersionUID = 3546924667060303927L;
  private static MissingProperties singleton;
  
  public synchronized Object setProperty(String key, String value)
  {
    throw new UnsupportedOperationException();
  }
  
  public synchronized Object put(Object key, Object value)
  {
    throw new UnsupportedOperationException();
  }
  
  public static MissingProperties getInstance()
  {
    if (singleton == null) {
      singleton = new MissingProperties();
    }
    return singleton;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.build.AbstractScriptGenerator.MissingProperties
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.build;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.build.ant.AntScript;
import org.eclipse.pde.internal.build.site.BuildTimeFeature;
import org.eclipse.pde.internal.build.site.BuildTimeSite;
import org.eclipse.pde.internal.build.site.BuildTimeSiteContentProvider;
import org.eclipse.pde.internal.build.site.BuildTimeSiteFactory;
import org.eclipse.pde.internal.build.site.PDEState;
import org.eclipse.pde.internal.build.site.compatibility.SiteManager;
import org.osgi.framework.Version;

public abstract class AbstractScriptGenerator
  implements IXMLConstants, IPDEBuildConstants, IBuildPropertiesConstants
{
  private static final FilenameFilter METADATA_REPO_FILTER = new FilenameFilter()
  {
    public boolean accept(File dir, String name)
    {
      return (name.startsWith("content.")) || (name.startsWith("compositeContent.")) || (name.endsWith(".profile")) || (name.endsWith(".profile.gz"));
    }
  };
  private static final FilenameFilter ARTIFACT_REPO_FILTER = new FilenameFilter()
  {
    public boolean accept(File dir, String name)
    {
      return (name.startsWith("artifacts.")) || (name.startsWith("compositeArtifacts."));
    }
  };
  private static Properties immutableAntProperties = null;
  protected static boolean embeddedSource = false;
  protected static boolean forceUpdateJarFormat = false;
  private static List configInfos;
  protected static String workingDirectory;
  protected static boolean buildingOSGi = true;
  protected URI[] contextMetadata = null;
  protected URI[] contextArtifacts = null;
  protected AntScript script;
  protected Properties platformProperties;
  protected String productQualifier;
  private static PDEUIStateWrapper pdeUIState;
  protected String[] sitePaths;
  protected String[] pluginPath;
  protected BuildTimeSiteFactory siteFactory;
  protected boolean filterState = false;
  protected List featuresForFilterRoots = new ArrayList();
  protected List pluginsForFilterRoots = new ArrayList();
  protected boolean filterP2Base = false;
  protected boolean reportResolutionErrors;
  
  static
  {
    configInfos = new ArrayList(1);
    configInfos.add(Config.genericConfig());
  }
  
  public static List getConfigInfos()
  {
    return configInfos;
  }
  
  public abstract void generate()
    throws CoreException;
  
  protected static void setStaticAntProperties(Properties properties)
  {
    if (properties == null)
    {
      immutableAntProperties = new Properties();
      org.eclipse.pde.internal.build.builder.BuildDirector.p2Gathering = false;
    }
    else
    {
      immutableAntProperties = properties;
    }
    if (getImmutableAntProperty("packagerMode") == null) {
      immutableAntProperties.setProperty("packagerMode", "false");
    }
    if ((!getPropertyAsBoolean("packagerMode")) || (getImmutableAntProperty("packagerAsNormalizer") == null)) {
      immutableAntProperties.setProperty("packagerAsNormalizer", "true");
    }
    if (getPropertyAsBoolean("p2.gathering")) {
      org.eclipse.pde.internal.build.builder.BuildDirector.p2Gathering = true;
    }
  }
  
  public static String getImmutableAntProperty(String key)
  {
    return getImmutableAntProperty(key, null);
  }
  
  public static boolean getPropertyAsBoolean(String key)
  {
    String booleanValue = getImmutableAntProperty(key, null);
    if ("true".equalsIgnoreCase(booleanValue)) {
      return true;
    }
    return false;
  }
  
  public static String getImmutableAntProperty(String key, String defaultValue)
  {
    if ((immutableAntProperties == null) || (!immutableAntProperties.containsKey(key))) {
      return defaultValue;
    }
    Object obj = immutableAntProperties.get(key);
    return (obj instanceof String) ? (String)obj : null;
  }
  
  public static void setConfigInfo(String spec)
    throws CoreException
  {
    configInfos.clear();
    String[] configs = Utils.getArrayFromStringWithBlank(spec, "&");
    configInfos = new ArrayList(configs.length);
    String[] os = new String[configs.length];
    String[] ws = new String[configs.length];
    String[] archs = new String[configs.length];
    for (int i = 0; i < configs.length; i++)
    {
      String[] configElements = Utils.getArrayFromStringWithBlank(configs[i], ",");
      if (configElements.length != 3)
      {
        IStatus error = new Status(4, "org.eclipse.pde.build", 22, NLS.bind(Messages.error_configWrongFormat, configs[i]), null);
        throw new CoreException(error);
      }
      Config aConfig = new Config(configs[i]);
      if (aConfig.equals(Config.genericConfig())) {
        configInfos.add(Config.genericConfig());
      } else {
        configInfos.add(aConfig);
      }
      os[i] = aConfig.getOs();
      ws[i] = aConfig.getWs();
      archs[i] = aConfig.getArch();
    }
    SiteManager.setOS(Utils.getStringFromArray(os, ","));
    SiteManager.setWS(Utils.getStringFromArray(ws, ","));
    SiteManager.setArch(Utils.getStringFromArray(archs, ","));
  }
  
  public void setWorkingDirectory(String location)
  {
    workingDirectory = location;
  }
  
  public String getLocation(BundleDescription model)
  {
    return model.getLocation();
  }
  
  /* Error */
  public static Properties readProperties(String location, String fileName, int errorLevel)
    throws CoreException
  {
    // Byte code:
    //   0: aload_0
    //   1: ifnonnull +49 -> 50
    //   4: iload_2
    //   5: iconst_1
    //   6: if_icmpeq +40 -> 46
    //   9: iload_2
    //   10: ifeq +36 -> 46
    //   13: getstatic 274	org/eclipse/pde/internal/build/Messages:exception_missingFile	Ljava/lang/String;
    //   16: aload_1
    //   17: invokestatic 206	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   20: astore_3
    //   21: invokestatic 277	org/eclipse/pde/internal/build/BundleHelper:getDefault	()Lorg/eclipse/pde/internal/build/BundleHelper;
    //   24: invokevirtual 283	org/eclipse/pde/internal/build/BundleHelper:getLog	()Lorg/eclipse/core/runtime/ILog;
    //   27: new 197	org/eclipse/core/runtime/Status
    //   30: dup
    //   31: iload_2
    //   32: ldc -57
    //   34: bipush 10
    //   36: aload_3
    //   37: aconst_null
    //   38: invokespecial 212	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   41: invokeinterface 287 2 0
    //   46: invokestatic 292	org/eclipse/pde/internal/build/AbstractScriptGenerator$MissingProperties:getInstance	()Lorg/eclipse/pde/internal/build/AbstractScriptGenerator$MissingProperties;
    //   49: areturn
    //   50: new 131	java/util/Properties
    //   53: dup
    //   54: invokespecial 133	java/util/Properties:<init>	()V
    //   57: astore_3
    //   58: new 298	java/io/File
    //   61: dup
    //   62: aload_0
    //   63: aload_1
    //   64: invokespecial 300	java/io/File:<init>	(Ljava/lang/String;Ljava/lang/String;)V
    //   67: astore 4
    //   69: new 303	java/io/BufferedInputStream
    //   72: dup
    //   73: new 305	java/io/FileInputStream
    //   76: dup
    //   77: aload 4
    //   79: invokespecial 307	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   82: invokespecial 310	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   85: astore 5
    //   87: aload_3
    //   88: aload 5
    //   90: invokevirtual 313	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   93: goto +13 -> 106
    //   96: astore 6
    //   98: aload 5
    //   100: invokevirtual 316	java/io/InputStream:close	()V
    //   103: aload 6
    //   105: athrow
    //   106: aload 5
    //   108: invokevirtual 316	java/io/InputStream:close	()V
    //   111: goto +92 -> 203
    //   114: pop
    //   115: iload_2
    //   116: iconst_1
    //   117: if_icmpeq +43 -> 160
    //   120: iload_2
    //   121: ifeq +39 -> 160
    //   124: getstatic 274	org/eclipse/pde/internal/build/Messages:exception_missingFile	Ljava/lang/String;
    //   127: aload 4
    //   129: invokestatic 206	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   132: astore 5
    //   134: invokestatic 277	org/eclipse/pde/internal/build/BundleHelper:getDefault	()Lorg/eclipse/pde/internal/build/BundleHelper;
    //   137: invokevirtual 283	org/eclipse/pde/internal/build/BundleHelper:getLog	()Lorg/eclipse/core/runtime/ILog;
    //   140: new 197	org/eclipse/core/runtime/Status
    //   143: dup
    //   144: iload_2
    //   145: ldc -57
    //   147: bipush 10
    //   149: aload 5
    //   151: aconst_null
    //   152: invokespecial 212	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   155: invokeinterface 287 2 0
    //   160: invokestatic 292	org/eclipse/pde/internal/build/AbstractScriptGenerator$MissingProperties:getInstance	()Lorg/eclipse/pde/internal/build/AbstractScriptGenerator$MissingProperties;
    //   163: astore_3
    //   164: goto +39 -> 203
    //   167: astore 5
    //   169: getstatic 321	org/eclipse/pde/internal/build/Messages:exception_readingFile	Ljava/lang/String;
    //   172: aload 4
    //   174: invokestatic 206	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   177: astore 6
    //   179: new 127	org/eclipse/core/runtime/CoreException
    //   182: dup
    //   183: new 197	org/eclipse/core/runtime/Status
    //   186: dup
    //   187: iconst_4
    //   188: ldc -57
    //   190: bipush 10
    //   192: aload 6
    //   194: aload 5
    //   196: invokespecial 212	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   199: invokespecial 215	org/eclipse/core/runtime/CoreException:<init>	(Lorg/eclipse/core/runtime/IStatus;)V
    //   202: athrow
    //   203: aload_3
    //   204: areturn
    // Line number table:
    //   Java source line #201	-> byte code offset #0
    //   Java source line #202	-> byte code offset #4
    //   Java source line #203	-> byte code offset #13
    //   Java source line #204	-> byte code offset #21
    //   Java source line #206	-> byte code offset #46
    //   Java source line #209	-> byte code offset #50
    //   Java source line #210	-> byte code offset #58
    //   Java source line #212	-> byte code offset #69
    //   Java source line #214	-> byte code offset #87
    //   Java source line #215	-> byte code offset #96
    //   Java source line #216	-> byte code offset #98
    //   Java source line #217	-> byte code offset #103
    //   Java source line #216	-> byte code offset #106
    //   Java source line #218	-> byte code offset #114
    //   Java source line #219	-> byte code offset #115
    //   Java source line #220	-> byte code offset #124
    //   Java source line #221	-> byte code offset #134
    //   Java source line #223	-> byte code offset #160
    //   Java source line #224	-> byte code offset #167
    //   Java source line #225	-> byte code offset #169
    //   Java source line #226	-> byte code offset #179
    //   Java source line #228	-> byte code offset #203
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	205	0	location	String
    //   0	205	1	fileName	String
    //   0	205	2	errorLevel	int
    //   20	17	3	message	String
    //   57	147	3	result	Properties
    //   67	106	4	file	File
    //   85	22	5	input	java.io.InputStream
    //   132	18	5	message	String
    //   167	28	5	e	IOException
    //   96	8	6	localObject	Object
    //   177	16	6	message	String
    //   114	1	11	localFileNotFoundException	FileNotFoundException
    // Exception table:
    //   from	to	target	type
    //   87	96	96	finally
    //   69	111	114	java/io/FileNotFoundException
    //   69	111	167	java/io/IOException
  }
  
  public static class MissingProperties
    extends Properties
  {
    private static final long serialVersionUID = 3546924667060303927L;
    private static MissingProperties singleton;
    
    public synchronized Object setProperty(String key, String value)
    {
      throw new UnsupportedOperationException();
    }
    
    public synchronized Object put(Object key, Object value)
    {
      throw new UnsupportedOperationException();
    }
    
    public static MissingProperties getInstance()
    {
      if (singleton == null) {
        singleton = new MissingProperties();
      }
      return singleton;
    }
  }
  
  public void openScript(String scriptLocation, String scriptName)
    throws CoreException
  {
    if (script != null) {
      return;
    }
    script = newAntScript(scriptLocation, scriptName);
  }
  
  protected static AntScript newAntScript(String scriptLocation, String scriptName)
    throws CoreException
  {
    result = null;
    try
    {
      OutputStream scriptStream = new BufferedOutputStream(new FileOutputStream(scriptLocation + '/' + scriptName));
      try
      {
        result = new AntScript(scriptStream);
      }
      catch (IOException e)
      {
        try
        {
          scriptStream.close();
          String message = NLS.bind(Messages.exception_writingFile, scriptLocation + '/' + scriptName);
          throw new CoreException(new Status(4, "org.eclipse.pde.build", 12, message, e));
        }
        catch (IOException localIOException1) {}
      }
      String message;
      return result;
    }
    catch (FileNotFoundException e)
    {
      message = NLS.bind(Messages.exception_writingFile, scriptLocation + '/' + scriptName);
      throw new CoreException(new Status(4, "org.eclipse.pde.build", 12, message, e));
    }
  }
  
  public void closeScript()
  {
    script.close();
  }
  
  public void setBuildingOSGi(boolean b)
  {
    buildingOSGi = b;
  }
  
  public static boolean isBuildingOSGi()
  {
    return buildingOSGi;
  }
  
  public static String getWorkingDirectory()
  {
    return workingDirectory;
  }
  
  public static String getDefaultOutputFormat()
  {
    return "zip";
  }
  
  public static boolean getDefaultEmbeddedSource()
  {
    return false;
  }
  
  public static void setEmbeddedSource(boolean embed)
  {
    embeddedSource = embed;
  }
  
  public static boolean getForceUpdateJarFormat()
  {
    return false;
  }
  
  public static void setForceUpdateJar(boolean force)
  {
    forceUpdateJarFormat = force;
  }
  
  public static String getDefaultConfigInfos()
  {
    return "*, *, *";
  }
  
  public static boolean getDefaultBuildingOSGi()
  {
    return true;
  }
  
  protected static boolean loadP2Class()
  {
    try
    {
      BundleHelper.getDefault().getClass().getClassLoader().loadClass("org.eclipse.equinox.p2.publisher.Publisher");
      return true;
    }
    catch (Throwable localThrowable) {}
    return false;
  }
  
  public BuildTimeSite getSite(boolean refresh)
    throws CoreException
  {
    if ((siteFactory != null) && (!refresh)) {
      return siteFactory.createSite();
    }
    BuildTimeSiteFactory factory = new BuildTimeSiteFactory();
    factory.setFilterState(filterState);
    factory.setFilterRoots(featuresForFilterRoots, pluginsForFilterRoots);
    factory.setReportResolutionErrors(reportResolutionErrors);
    factory.setFilterP2Base(filterP2Base);
    factory.setSitePaths(getPaths());
    factory.setEESources(getEESources());
    factory.setInitialState(pdeUIState);
    
    BuildTimeSite result = factory.createSite();
    siteFactory = factory;
    if (platformProperties != null) {
      result.setPlatformPropeties(platformProperties);
    }
    File baseProfile = result.getSiteContentProvider().getBaseProfile();
    if (baseProfile != null)
    {
      List repos = getAssociatedRepositories(baseProfile);
      if (repos.size() > 0) {
        addContextRepos((URI[])repos.toArray(new URI[repos.size()]));
      }
    }
    return result;
  }
  
  private String[] getPaths()
  {
    if (sitePaths == null) {
      if (pluginPath != null)
      {
        sitePaths = new String[pluginPath.length + 1];
        System.arraycopy(pluginPath, 0, sitePaths, 0, pluginPath.length);
        sitePaths[(sitePaths.length - 1)] = workingDirectory;
      }
      else
      {
        sitePaths = new String[] { workingDirectory };
      }
    }
    return sitePaths;
  }
  
  protected String[] getEESources()
  {
    return null;
  }
  
  public void setBuildSiteFactory(BuildTimeSiteFactory siteFactory)
  {
    this.siteFactory = siteFactory;
  }
  
  public String[] getPluginPath()
  {
    return pluginPath;
  }
  
  public void setPluginPath(String[] path)
  {
    pluginPath = path;
  }
  
  public void setPDEState(State state)
  {
    ensurePDEUIStateNotNull();
    pdeUIState.setState(state);
  }
  
  public void setStateExtraData(HashMap classpath, Map patchData)
  {
    setStateExtraData(classpath, patchData, null);
  }
  
  public void setStateExtraData(HashMap classpath, Map patchData, Map outputFolders)
  {
    ensurePDEUIStateNotNull();
    pdeUIState.setExtraData(classpath, patchData, outputFolders);
  }
  
  public void setNextId(long nextId)
  {
    ensurePDEUIStateNotNull();
    pdeUIState.setNextId(nextId);
  }
  
  protected void flushState()
  {
    pdeUIState = null;
  }
  
  private void ensurePDEUIStateNotNull()
  {
    if (pdeUIState == null) {
      pdeUIState = new PDEUIStateWrapper();
    }
  }
  
  protected boolean havePDEUIState()
  {
    return pdeUIState != null;
  }
  
  public ProductFile loadProduct(String product)
    throws CoreException
  {
    return loadProduct(product, null);
  }
  
  public ProductFile loadProduct(String product, String os)
    throws CoreException
  {
    if ((product == null) || (product.startsWith("${")) || (product.length() == 0)) {
      return null;
    }
    String productPath = findFile(product, false);
    File f = null;
    if (productPath != null)
    {
      f = new File(productPath);
    }
    else
    {
      f = new File(product);
      if ((!f.exists()) || (!f.isFile()))
      {
        f = new File(getWorkingDirectory(), product);
        if ((!f.exists()) || (!f.isFile()))
        {
          f = new File(getWorkingDirectory() + "/" + "plugins", product);
          if ((!f.exists()) || (!f.isFile())) {
            f = new File(getWorkingDirectory() + '/' + "features", product);
          }
        }
      }
    }
    return new ProductFile(f.getAbsolutePath(), os);
  }
  
  protected String findFile(String location, boolean makeRelative)
  {
    if ((location == null) || (location.length() == 0)) {
      return null;
    }
    if (new File(location).exists()) {
      return location;
    }
    try
    {
      state = getSite(false).getRegistry();
    }
    catch (CoreException e)
    {
      PDEState state;
      BundleHelper.getDefault().getLog().log(e.getStatus());
      return null;
    }
    PDEState state;
    Path path = new Path(location);
    String id = path.segment(0);
    BundleDescription[] matches = state.getState().getBundles(id);
    if ((matches != null) && (matches.length != 0))
    {
      BundleDescription bundle = matches[0];
      if (bundle != null)
      {
        String result = checkFile(new Path(bundle.getLocation()), path, makeRelative);
        if (result != null) {
          return result;
        }
      }
    }
    BuildTimeFeature feature = null;
    try
    {
      feature = getSite(false).findFeature(id, null, false);
    }
    catch (CoreException e)
    {
      BundleHelper.getDefault().getLog().log(e.getStatus());
    }
    if (feature == null) {
      return null;
    }
    String featureRoot = feature.getRootLocation();
    if (featureRoot != null) {
      return checkFile(new Path(featureRoot), path, makeRelative);
    }
    return null;
  }
  
  protected String findConfigFile(ProductFile productFile, String os)
  {
    String path = productFile.getConfigIniPath(os);
    if (path == null) {
      return null;
    }
    String result = findFile(path, false);
    if (result != null) {
      return result;
    }
    File f = new File(path);
    if ((f.exists()) && (f.isFile())) {
      return f.getAbsolutePath();
    }
    f = new File(getWorkingDirectory(), path);
    if ((f.exists()) && (f.isFile())) {
      return f.getAbsolutePath();
    }
    f = new File(getWorkingDirectory() + "/" + "plugins", path);
    if ((f.exists()) && (f.isFile())) {
      return f.getAbsolutePath();
    }
    f = new File(new File(productFile.getLocation()).getParent(), path);
    if ((f.exists()) && (f.isFile())) {
      return f.getAbsolutePath();
    }
    return null;
  }
  
  private String checkFile(IPath base, Path target, boolean makeRelative)
  {
    IPath path = base.append(target.removeFirstSegments(1));
    String result = path.toOSString();
    if (!new File(result).exists()) {
      return null;
    }
    if (makeRelative) {
      return Utils.makeRelative(path, new Path(workingDirectory)).toOSString();
    }
    return result;
  }
  
  public void setFilterState(boolean filter)
  {
    filterState = filter;
  }
  
  public void setFilterP2Base(boolean filter)
  {
    filterP2Base = filter;
  }
  
  private static URI getDownloadCacheLocation(IProvisioningAgent agent)
  {
    IAgentLocation location = (IAgentLocation)agent.getService(IAgentLocation.SERVICE_NAME);
    if (location == null) {
      return null;
    }
    return URIUtil.append(location.getDataArea("org.eclipse.equinox.p2.core"), "cache/");
  }
  
  protected void setContextArtifacts(URI[] uris)
  {
    contextArtifacts = uris;
  }
  
  protected void setContextMetadata(URI[] uris)
  {
    contextMetadata = uris;
  }
  
  public void setContextMetadataRepositories(URI[] uris)
  {
    Set uriSet = new HashSet();
    uriSet.addAll(Arrays.asList(uris));
    for (int i = 0; i < uris.length; i++)
    {
      File uriFile = URIUtil.toFile(uris[i]);
      uriSet.addAll(getAssociatedRepositories(uriFile));
    }
    addContextRepos((URI[])uriSet.toArray(new URI[uriSet.size()]));
  }
  
  protected void addContextRepos(URI[] repos)
  {
    List metadata = filterRepos(repos, METADATA_REPO_FILTER);
    List artifacts = filterRepos(repos, ARTIFACT_REPO_FILTER);
    if (contextMetadata != null)
    {
      Set uriSet = new HashSet();
      uriSet.addAll(Arrays.asList(contextMetadata));
      uriSet.addAll(metadata);
      contextMetadata = ((URI[])uriSet.toArray(new URI[uriSet.size()]));
    }
    else
    {
      contextMetadata = ((URI[])metadata.toArray(new URI[metadata.size()]));
    }
    if (contextArtifacts != null)
    {
      Set uriSet = new HashSet();
      uriSet.addAll(Arrays.asList(contextArtifacts));
      uriSet.addAll(artifacts);
      contextArtifacts = ((URI[])uriSet.toArray(new URI[uriSet.size()]));
    }
    else
    {
      contextArtifacts = ((URI[])artifacts.toArray(new URI[artifacts.size()]));
    }
  }
  
  private List filterRepos(URI[] contexts, FilenameFilter repoFilter)
  {
    if (contexts == null) {
      return null;
    }
    ArrayList result = new ArrayList();
    for (int i = 0; i < contexts.length; i++)
    {
      File repo = URIUtil.toFile(contexts[i]);
      if (repo == null)
      {
        result.add(contexts[i]);
      }
      else
      {
        String[] list = repo.list(repoFilter);
        if ((list != null) && (list.length > 0)) {
          result.add(contexts[i]);
        }
      }
    }
    return result;
  }
  
  private List getAssociatedRepositories(File profileFile)
  {
    if ((profileFile == null) || (!profileFile.exists()) || (!profileFile.getName().endsWith(".profile"))) {
      return Collections.EMPTY_LIST;
    }
    ArrayList result = new ArrayList();
    URI profileURI = profileFile.toURI();
    result.add(profileURI);
    
    Map profileInfo = extractProfileInformation(profileFile);
    if (profileInfo == null) {
      return result;
    }
    File areaFile = new File((String)profileInfo.get(PROFILE_DATA_AREA));
    if (areaFile.exists())
    {
      IProvisioningAgent agent = BundleHelper.getDefault().getProvisioningAgent(areaFile.toURI());
      if (agent != null)
      {
        IProfileRegistry registry = new SimpleProfileRegistry(agent, (File)profileInfo.get(PROFILE_REGISTRY), null, false);
        try
        {
          long timestamp = ((Long)profileInfo.get(PROFILE_TIMESTAMP)).longValue();
          String profileId = (String)profileInfo.get(PROFILE_ID);
          if (timestamp == -1L)
          {
            long[] timestamps = registry.listProfileTimestamps(profileId);
            if (timestamps.length > 0) {
              timestamp = timestamps[(timestamps.length - 1)];
            }
          }
          if (timestamp > 0L)
          {
            IProfile profile = registry.getProfile(profileId, timestamp);
            if (profile != null)
            {
              String cache = profile.getProperty("org.eclipse.equinox.p2.cache");
              if (cache != null)
              {
                File cacheFolder = new File(cache);
                if (cacheFolder.exists()) {
                  result.add(cacheFolder.toURI());
                } else {
                  result.add(areaFile.getParentFile().toURI());
                }
              }
              String sharedCache = profile.getProperty("org.eclipse.equinox.p2.cache.shared");
              if (sharedCache != null) {
                result.add(new File(cache).toURI());
              }
              String dropinRepositories = profile.getProperty("org.eclipse.equinox.p2.cache.extensions");
              if (dropinRepositories != null)
              {
                StringTokenizer tokenizer = new StringTokenizer(dropinRepositories, "|");
                while (tokenizer.hasMoreTokens()) {
                  try
                  {
                    result.add(new URI(tokenizer.nextToken()));
                  }
                  catch (URISyntaxException localURISyntaxException) {}
                }
              }
            }
          }
        }
        catch (IllegalStateException localIllegalStateException)
        {
          result.add(areaFile.getParentFile().toURI());
        }
        URI download = getDownloadCacheLocation(agent);
        if (URIUtil.toFile(download).exists()) {
          result.add(download);
        }
      }
    }
    return result;
  }
  
  private static String PROFILE_TIMESTAMP = "timestamp";
  private static String PROFILE_ID = "profileId";
  private static String PROFILE_DATA_AREA = "dataArea";
  private static String PROFILE_REGISTRY = "registry";
  
  private static Map extractProfileInformation(File target)
  {
    if ((target == null) || (!target.exists())) {
      return null;
    }
    IPath path = new Path(target.getAbsolutePath());
    if ((!path.lastSegment().endsWith("profile")) && (!path.lastSegment().endsWith("profile.gz"))) {
      return null;
    }
    if (path.segmentCount() < 4) {
      return null;
    }
    Map results = new HashMap();
    results.put(PROFILE_TIMESTAMP, new Long(-1L));
    
    String profileId = null;
    if (target.isFile())
    {
      if (path.segmentCount() < 5) {
        return null;
      }
      String timestamp = path.lastSegment();
      int idx = timestamp.indexOf('.');
      if (idx > 0)
      {
        timestamp = timestamp.substring(0, idx);
        try
        {
          results.put(PROFILE_TIMESTAMP, new Long(timestamp));
        }
        catch (NumberFormatException localNumberFormatException) {}
      }
      path = path.removeLastSegments(1);
      profileId = path.removeFileExtension().lastSegment();
    }
    else
    {
      profileId = path.removeFileExtension().lastSegment();
    }
    profileId = SimpleProfileRegistry.unescape(profileId);
    results.put(PROFILE_ID, profileId);
    
    path = path.removeLastSegments(1);
    results.put(PROFILE_REGISTRY, path.toFile());
    
    path = path.removeLastSegments(2);
    results.put(PROFILE_DATA_AREA, path.toOSString());
    
    return results;
  }
  
  public URI[] getContextMetadata()
  {
    return contextMetadata;
  }
  
  public URI[] getContextArtifacts()
  {
    return contextArtifacts;
  }
  
  public void setProductQualifier(String value)
  {
    productQualifier = value;
  }
  
  /* Error */
  public void setPlatformProperties(String filename)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnull +13 -> 14
    //   4: aload_1
    //   5: invokevirtual 909	java/lang/String:trim	()Ljava/lang/String;
    //   8: invokevirtual 573	java/lang/String:length	()I
    //   11: ifne +4 -> 15
    //   14: return
    //   15: new 298	java/io/File
    //   18: dup
    //   19: aload_1
    //   20: invokespecial 580	java/io/File:<init>	(Ljava/lang/String;)V
    //   23: astore_2
    //   24: aload_2
    //   25: invokevirtual 581	java/io/File:exists	()Z
    //   28: ifne +4 -> 32
    //   31: return
    //   32: aload_0
    //   33: new 131	java/util/Properties
    //   36: dup
    //   37: invokespecial 133	java/util/Properties:<init>	()V
    //   40: putfield 472	org/eclipse/pde/internal/build/AbstractScriptGenerator:platformProperties	Ljava/util/Properties;
    //   43: aconst_null
    //   44: astore_3
    //   45: new 303	java/io/BufferedInputStream
    //   48: dup
    //   49: new 305	java/io/FileInputStream
    //   52: dup
    //   53: aload_2
    //   54: invokespecial 307	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   57: invokespecial 310	java/io/BufferedInputStream:<init>	(Ljava/io/InputStream;)V
    //   60: astore_3
    //   61: aload_0
    //   62: getfield 472	org/eclipse/pde/internal/build/AbstractScriptGenerator:platformProperties	Ljava/util/Properties;
    //   65: aload_3
    //   66: invokevirtual 313	java/util/Properties:load	(Ljava/io/InputStream;)V
    //   69: goto +80 -> 149
    //   72: astore 4
    //   74: aload_0
    //   75: aconst_null
    //   76: putfield 472	org/eclipse/pde/internal/build/AbstractScriptGenerator:platformProperties	Ljava/util/Properties;
    //   79: getstatic 912	org/eclipse/pde/internal/build/Messages:error_loading_platform_properties	Ljava/lang/String;
    //   82: aload_1
    //   83: invokestatic 206	org/eclipse/osgi/util/NLS:bind	(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;
    //   86: astore 5
    //   88: new 197	org/eclipse/core/runtime/Status
    //   91: dup
    //   92: iconst_2
    //   93: ldc -57
    //   95: aload 5
    //   97: aload 4
    //   99: invokespecial 915	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   102: astore 6
    //   104: invokestatic 277	org/eclipse/pde/internal/build/BundleHelper:getDefault	()Lorg/eclipse/pde/internal/build/BundleHelper;
    //   107: invokevirtual 283	org/eclipse/pde/internal/build/BundleHelper:getLog	()Lorg/eclipse/core/runtime/ILog;
    //   110: aload 6
    //   112: invokeinterface 287 2 0
    //   117: aload_3
    //   118: ifnull +43 -> 161
    //   121: aload_3
    //   122: invokevirtual 316	java/io/InputStream:close	()V
    //   125: goto +36 -> 161
    //   128: pop
    //   129: goto +32 -> 161
    //   132: astore 7
    //   134: aload_3
    //   135: ifnull +11 -> 146
    //   138: aload_3
    //   139: invokevirtual 316	java/io/InputStream:close	()V
    //   142: goto +4 -> 146
    //   145: pop
    //   146: aload 7
    //   148: athrow
    //   149: aload_3
    //   150: ifnull +11 -> 161
    //   153: aload_3
    //   154: invokevirtual 316	java/io/InputStream:close	()V
    //   157: goto +4 -> 161
    //   160: pop
    //   161: return
    // Line number table:
    //   Java source line #766	-> byte code offset #0
    //   Java source line #767	-> byte code offset #14
    //   Java source line #768	-> byte code offset #15
    //   Java source line #769	-> byte code offset #24
    //   Java source line #770	-> byte code offset #31
    //   Java source line #771	-> byte code offset #32
    //   Java source line #772	-> byte code offset #43
    //   Java source line #774	-> byte code offset #45
    //   Java source line #775	-> byte code offset #61
    //   Java source line #776	-> byte code offset #72
    //   Java source line #777	-> byte code offset #74
    //   Java source line #778	-> byte code offset #79
    //   Java source line #779	-> byte code offset #88
    //   Java source line #780	-> byte code offset #104
    //   Java source line #782	-> byte code offset #117
    //   Java source line #784	-> byte code offset #121
    //   Java source line #785	-> byte code offset #128
    //   Java source line #781	-> byte code offset #132
    //   Java source line #782	-> byte code offset #134
    //   Java source line #784	-> byte code offset #138
    //   Java source line #785	-> byte code offset #145
    //   Java source line #788	-> byte code offset #146
    //   Java source line #782	-> byte code offset #149
    //   Java source line #784	-> byte code offset #153
    //   Java source line #785	-> byte code offset #160
    //   Java source line #789	-> byte code offset #161
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	162	0	this	AbstractScriptGenerator
    //   0	162	1	filename	String
    //   23	31	2	file	File
    //   44	110	3	input	java.io.InputStream
    //   72	26	4	e	IOException
    //   86	10	5	message	String
    //   102	9	6	status	IStatus
    //   132	15	7	localObject	Object
    //   128	1	8	localIOException1	IOException
    //   145	1	9	localIOException2	IOException
    //   160	1	10	localIOException3	IOException
    // Exception table:
    //   from	to	target	type
    //   45	69	72	java/io/IOException
    //   121	125	128	java/io/IOException
    //   45	117	132	final
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

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-2017. Infinite Loop Ltd