pdepublishing-ant

16:50:55.868 INFO  jd.cli.Main - Decompiling pdepublishing-ant.jar
package org.eclipse.equinox.internal.p2.publisher.ant;

import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.core.runtime.URIUtil;

public class AbstractPublishTask$RepoEntry
{
  private URI repoLocation;
  private Boolean metadata = null;
  private Boolean artifact = null;
  
  public boolean isMetadataRepository()
  {
    if (metadata != null) {
      return metadata.booleanValue();
    }
    return !Boolean.TRUE.equals(artifact);
  }
  
  public boolean isArtifactRepository()
  {
    if (artifact != null) {
      return artifact.booleanValue();
    }
    return !Boolean.TRUE.equals(metadata);
  }
  
  public URI getRepositoryLocation()
  {
    return repoLocation;
  }
  
  public void setLocation(String location)
  {
    try
    {
      repoLocation = URIUtil.fromString(location);
    }
    catch (URISyntaxException localURISyntaxException)
    {
      throw new IllegalArgumentException("Repository location (" + location + ") must be a URL.");
    }
  }
  
  public void setMetadata(boolean metadata)
  {
    this.metadata = Boolean.valueOf(metadata);
  }
  
  public void setArtifact(boolean artifact)
  {
    this.artifact = Boolean.valueOf(artifact);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.AbstractPublishTask.RepoEntry
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.tools.ant.Task;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
import org.eclipse.equinox.internal.p2.publisher.Messages;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.publisher.Publisher;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.publishing.Activator;

public abstract class AbstractPublishTask
  extends Task
{
  protected static final String ANT_PROPERTY_PREFIX = "${";
  
  public static class RepoEntry
  {
    private URI repoLocation;
    private Boolean metadata = null;
    private Boolean artifact = null;
    
    public boolean isMetadataRepository()
    {
      if (metadata != null) {
        return metadata.booleanValue();
      }
      return !Boolean.TRUE.equals(artifact);
    }
    
    public boolean isArtifactRepository()
    {
      if (artifact != null) {
        return artifact.booleanValue();
      }
      return !Boolean.TRUE.equals(metadata);
    }
    
    public URI getRepositoryLocation()
    {
      return repoLocation;
    }
    
    public void setLocation(String location)
    {
      try
      {
        repoLocation = URIUtil.fromString(location);
      }
      catch (URISyntaxException localURISyntaxException)
      {
        throw new IllegalArgumentException("Repository location (" + location + ") must be a URL.");
      }
    }
    
    public void setMetadata(boolean metadata)
    {
      this.metadata = Boolean.valueOf(metadata);
    }
    
    public void setArtifact(boolean artifact)
    {
      this.artifact = Boolean.valueOf(artifact);
    }
  }
  
  protected boolean compress = false;
  protected boolean reusePackedFiles = false;
  protected boolean append = true;
  protected boolean publish = true;
  protected String source = null;
  protected URI metadataLocation;
  protected String metadataRepoName;
  protected URI artifactLocation;
  protected String artifactRepoName;
  protected PublisherInfo provider = null;
  protected List<RepoEntry> contextRepositories = new ArrayList();
  
  protected IProvisioningAgent getProvisioningAgent()
  {
    return (IProvisioningAgent)ServiceHelper.getService(Activator.getContext(), IProvisioningAgent.SERVICE_NAME);
  }
  
  protected IStatus createConfigurationEror(String message)
  {
    return new Status(4, "org.eclipse.equinox.p2.publisher", message);
  }
  
  private boolean isEmpty(IArtifactRepository repo)
  {
    IQueryResult<IArtifactKey> result = repo.query(QueryUtil.createLimitQuery(ArtifactKeyQuery.ALL_KEYS, 1), null);
    return result.isEmpty();
  }
  
  protected void initializeRepositories(PublisherInfo info)
    throws ProvisionException
  {
    if (artifactLocation != null)
    {
      IArtifactRepository repo = Publisher.createArtifactRepository(getProvisioningAgent(), artifactLocation, artifactRepoName, compress, reusePackedFiles);
      if ((!append) && (!isEmpty(repo)))
      {
        File repoLocation = URIUtil.toFile(artifactLocation);
        if ((repoLocation != null) && (source != null))
        {
          if (repoLocation.isFile()) {
            repoLocation = repoLocation.getParentFile();
          }
          if (repoLocation.equals(new File(source))) {
            throw new IllegalArgumentException(NLS.bind(Messages.exception_artifactRepoNoAppendDestroysInput, URIUtil.toUnencodedString(artifactLocation)));
          }
        }
        repo.removeAll(new NullProgressMonitor());
      }
      info.setArtifactRepository(repo);
    }
    else if ((info.getArtifactOptions() & 0x2) > 0)
    {
      throw new ProvisionException(createConfigurationEror(Messages.exception_noArtifactRepo));
    }
    if (metadataLocation == null) {
      throw new ProvisionException(createConfigurationEror(Messages.exception_noMetadataRepo));
    }
    info.setMetadataRepository(Publisher.createMetadataRepository(getProvisioningAgent(), metadataLocation, metadataRepoName, append, compress));
    if (contextRepositories.size() > 0)
    {
      CompositeMetadataRepository contextMetadata = CompositeMetadataRepository.createMemoryComposite(getProvisioningAgent());
      CompositeArtifactRepository contextArtifact = CompositeArtifactRepository.createMemoryComposite(getProvisioningAgent());
      for (Iterator localIterator = contextRepositories.iterator(); localIterator.hasNext();)
      {
        RepoEntry entry = (RepoEntry)localIterator.next();
        if ((contextMetadata != null) && (entry.isMetadataRepository())) {
          contextMetadata.addChild(entry.getRepositoryLocation());
        }
        if ((contextArtifact != null) && (entry.isArtifactRepository())) {
          contextArtifact.addChild(entry.getRepositoryLocation());
        }
      }
      if ((contextMetadata != null) && (contextMetadata.getChildren().size() > 0)) {
        info.setContextMetadataRepository(contextMetadata);
      }
      if ((contextArtifact != null) && (contextArtifact.getChildren().size() > 0)) {
        info.setContextArtifactRepository(contextArtifact);
      }
    }
  }
  
  protected PublisherInfo getInfo()
  {
    if (provider == null) {
      provider = new PublisherInfo();
    }
    if (publish) {
      provider.setArtifactOptions(provider.getArtifactOptions() | 0x2);
    }
    return provider;
  }
  
  public void setCompress(String value)
  {
    compress = Boolean.valueOf(value).booleanValue();
  }
  
  public void setReusePackedFiles(String value)
  {
    reusePackedFiles = Boolean.valueOf(value).booleanValue();
  }
  
  public void setAppend(String value)
  {
    append = Boolean.valueOf(value).booleanValue();
  }
  
  public void setPublishArtifacts(String value)
  {
    publish = Boolean.valueOf(value).booleanValue();
  }
  
  public void setArtifactRepository(String location)
  {
    try
    {
      artifactLocation = URIUtil.fromString(location);
    }
    catch (URISyntaxException localURISyntaxException)
    {
      throw new IllegalArgumentException("Artifact repository location (" + location + ") must be a URL.");
    }
  }
  
  public void setArtifactRepositoryName(String value)
  {
    artifactRepoName = value;
  }
  
  public void setMetadataRepository(String location)
  {
    try
    {
      metadataLocation = URIUtil.fromString(location);
    }
    catch (URISyntaxException localURISyntaxException)
    {
      throw new IllegalArgumentException("Metadata repository location (" + location + ") must be a URL.");
    }
  }
  
  public void setMetadataRepositoryName(String value)
  {
    metadataRepoName = value;
  }
  
  public void setRepository(String location)
  {
    setArtifactRepository(location);
    setMetadataRepository(location);
  }
  
  public void setRepositoryName(String name)
  {
    setArtifactRepositoryName(name);
    setMetadataRepositoryName(name);
  }
  
  public void addConfiguredContextRepository(RepoEntry repo)
  {
    contextRepositories.add(repo);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.AbstractPublishTask
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.publisher.IPublisherAction;
import org.eclipse.equinox.p2.publisher.Publisher;
import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction;

public class FeaturesAndBundlesPublisherTask
  extends AbstractPublishTask
{
  private ArrayList<Object> features = new ArrayList();
  private ArrayList<Object> bundles = new ArrayList();
  
  public void execute()
    throws BuildException
  {
    try
    {
      initializeRepositories(getInfo());
    }
    catch (ProvisionException e)
    {
      throw new BuildException("Unable to configure repositories", e);
    }
    File[] f = getLocations(features);
    File[] b = getLocations(bundles);
    
    ArrayList<IPublisherAction> actions = new ArrayList();
    if (f.length > 0) {
      actions.add(new FeaturesAction(f));
    }
    if (b.length > 0) {
      actions.add(new BundlesAction(b));
    }
    if (actions.size() > 0) {
      new Publisher(getInfo()).publish((IPublisherAction[])actions.toArray(new IPublisherAction[actions.size()]), new NullProgressMonitor());
    }
  }
  
  private File[] getLocations(List<Object> collection)
  {
    ArrayList<Object> results = new ArrayList();
    for (Iterator localIterator = collection.iterator(); localIterator.hasNext();)
    {
      Object obj = localIterator.next();
      if ((obj instanceof FileSet))
      {
        FileSet set = (FileSet)obj;
        
        DirectoryScanner scanner = set.getDirectoryScanner(getProject());
        String[][] elements = { scanner.getIncludedDirectories(), scanner.getIncludedFiles() };
        for (int i = 0; i < 2; i++) {
          for (int j = 0; j < elements[i].length; j++) {
            results.add(new File(set.getDir(), elements[i][j]));
          }
        }
      }
      else if ((obj instanceof File))
      {
        results.add(obj);
      }
    }
    return (File[])results.toArray(new File[results.size()]);
  }
  
  public FileSet createFeatures()
  {
    FileSet set = new FileSet();
    features.add(set);
    return set;
  }
  
  public FileSet createBundles()
  {
    FileSet set = new FileSet();
    bundles.add(set);
    return set;
  }
  
  public void setSource(String source)
  {
    this.source = source;
    features.add(new File(source, "features"));
    bundles.add(new File(source, "plugins"));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.FeaturesAndBundlesPublisherTask
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

public class ProductPublisherTask$AdviceElement
{
  public String kind;
  public String file;
  
  public void setKind(String kind)
  {
    this.kind = kind;
  }
  
  public void setFile(String file)
  {
    this.file = file;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.ProductPublisherTask.AdviceElement
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

public class ProductPublisherTask$ConfigElement
{
  public String os;
  public String ws;
  public String arch;
  
  public void setOs(String os)
  {
    this.os = os;
  }
  
  public void setWs(String ws)
  {
    this.ws = ws;
  }
  
  public void setArch(String arch)
  {
    this.arch = arch;
  }
  
  public String toString()
  {
    return ws + '.' + os + '.' + arch;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.ProductPublisherTask.ConfigElement
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.publisher.IPublisherAction;
import org.eclipse.equinox.p2.publisher.Publisher;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.actions.VersionAdvice;
import org.eclipse.equinox.p2.publisher.eclipse.ProductAction;

public class ProductPublisherTask
  extends AbstractPublishTask
{
  private String flavor;
  private String productFile;
  private String executables;
  
  public static class ConfigElement
  {
    public String os;
    public String ws;
    public String arch;
    
    public void setOs(String os)
    {
      this.os = os;
    }
    
    public void setWs(String ws)
    {
      this.ws = ws;
    }
    
    public void setArch(String arch)
    {
      this.arch = arch;
    }
    
    public String toString()
    {
      return ws + '.' + os + '.' + arch;
    }
  }
  
  public static class AdviceElement
  {
    public String kind;
    public String file;
    
    public void setKind(String kind)
    {
      this.kind = kind;
    }
    
    public void setFile(String file)
    {
      this.file = file;
    }
  }
  
  private List<ConfigElement> configurations = new ArrayList(3);
  private List<AdviceElement> advice = new ArrayList(3);
  
  public void execute()
    throws BuildException
  {
    try
    {
      initializeRepositories(getInfo());
    }
    catch (ProvisionException e)
    {
      throw new BuildException("Unable to configure repositories", e);
    }
    IProductDescriptor productDescriptor = null;
    try
    {
      productDescriptor = new ProductFile(productFile);
    }
    catch (Exception localException)
    {
      if (productFile == null) {
        throw new IllegalArgumentException("unable to load product file");
      }
    }
    if ((flavor == null) || (flavor.startsWith("${"))) {
      flavor = "tooling";
    }
    IPublisherAction action = new ProductAction(source, productDescriptor, flavor, executables != null ? new File(executables) : null);
    new Publisher(getInfo()).publish(new IPublisherAction[] { action }, new NullProgressMonitor());
  }
  
  protected PublisherInfo getInfo()
  {
    String[] configStrings = new String[configurations.size()];
    for (int i = 0; i < configurations.size(); i++) {
      configStrings[i] = ((ConfigElement)configurations.get(i)).toString();
    }
    PublisherInfo info = super.getInfo();
    info.setConfigurations(configStrings);
    processAdvice(info);
    return info;
  }
  
  protected void processAdvice(PublisherInfo info)
  {
    for (Iterator localIterator = advice.iterator(); localIterator.hasNext();)
    {
      AdviceElement element = (AdviceElement)localIterator.next();
      if ((kind != null) && (file != null)) {
        if ((kind.equals("featureVersions")) || (kind.equals("pluginVersions")))
        {
          VersionAdvice versionAdvice = new VersionAdvice();
          versionAdvice.load("org.eclipse.equinox.p2.iu", file, kind.startsWith("features") ? ".feature.group" : null);
          info.addAdvice(versionAdvice);
        }
      }
    }
  }
  
  public void setFlavor(String flavor)
  {
    this.flavor = flavor;
  }
  
  public void setProductFile(String productFile)
  {
    this.productFile = productFile;
  }
  
  public void setExecutables(String executables)
  {
    this.executables = executables;
  }
  
  public void setSource(String source)
  {
    this.source = source;
  }
  
  public void addConfiguredConfig(ConfigElement config)
  {
    configurations.add(config);
  }
  
  public void addConfiguredAdvice(AdviceElement element)
  {
    advice.add(element);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.ProductPublisherTask
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

import java.io.File;
import org.apache.tools.ant.BuildException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.publisher.IPublisherAction;
import org.eclipse.equinox.p2.publisher.Publisher;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.eclipse.EclipseInstallAction;

public class PublisherTask
  extends AbstractPublishTask
{
  protected boolean inplace = false;
  protected String[] configurations;
  protected String mode;
  private String flavor;
  private String operation;
  private String operationValue;
  private String root;
  private String rootVersion;
  private String versionAdvice;
  private String rootName;
  private String executableName;
  private IVersionedId[] topLevel;
  private boolean start;
  private String[] nonRootFiles;
  
  public void execute()
    throws BuildException
  {
    try
    {
      initialize(getInfo());
    }
    catch (ProvisionException e)
    {
      throw new BuildException("Unable to configure repositories", e);
    }
    createVersionAdvice();
    IPublisherAction[] actions = createActions();
    
    new Publisher(getInfo()).publish(actions, new NullProgressMonitor());
  }
  
  private IPublisherAction[] createActions()
  {
    if (operation == null) {
      return new IPublisherAction[0];
    }
    if (operation.equals("-update")) {
      return new IPublisherAction[0];
    }
    if (operation.equals("-source")) {
      return new IPublisherAction[] { new EclipseInstallAction(operationValue, root, Version.parseVersion(rootVersion), rootName, executableName, flavor, topLevel, nonRootFiles, start) };
    }
    return new IPublisherAction[0];
  }
  
  private void createVersionAdvice()
  {
    if (versionAdvice == null) {}
  }
  
  protected void initialize(PublisherInfo info)
    throws ProvisionException
  {
    if (inplace)
    {
      File sourceLocation = new File(source);
      if (metadataLocation == null) {
        metadataLocation = sourceLocation.toURI();
      }
      if (artifactLocation == null) {
        artifactLocation = sourceLocation.toURI();
      }
      info.setArtifactOptions(info.getArtifactOptions() | 0x1 | 0x2);
    }
    else
    {
      info.setArtifactOptions(info.getArtifactOptions() | 0x1 | 0x2 | 0x4);
    }
    initializeRepositories(info);
  }
  
  public void setBase(String value)
  {
    source = value;
  }
  
  public void setBundles(String value) {}
  
  public void setConfig(String value)
  {
    operation = "-config";
    operationValue = value;
  }
  
  public void setInplace(String value)
  {
    operation = "-inplace";
    operationValue = value;
  }
  
  public void setSource(String location)
  {
    source = location;
    operation = "-source";
    operationValue = location;
  }
  
  public void setUpdateSite(String value)
  {
    operation = "-update";
    operationValue = value;
  }
  
  /**
   * @deprecated
   */
  public void setExe(String value)
  {
    executableName = value;
  }
  
  public void setFeatures(String value) {}
  
  public void setFlavor(String value)
  {
    flavor = value;
  }
  
  /**
   * @deprecated
   */
  public void setLauncherConfig(String value) {}
  
  public void setNoDefaultIUs(String value) {}
  
  /**
   * @deprecated
   */
  public void setP2OS(String value) {}
  
  public void setProductFile(String file) {}
  
  public void setPublishArtifactRepository(String value)
  {
    getInfo().setArtifactOptions(getInfo().getArtifactOptions() | 0x1);
  }
  
  public void setPublishArtifacts(String value)
  {
    getInfo().setArtifactOptions(getInfo().getArtifactOptions() | 0x2);
  }
  
  public void setRoot(String value)
  {
    root = value;
  }
  
  public void setRootVersion(String value)
  {
    rootVersion = value;
  }
  
  public void setMode(String value)
  {
    mode = value;
  }
  
  public void setVersionAdvice(String value)
  {
    versionAdvice = value;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.PublisherTask
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.publisher.ant;

import org.eclipse.osgi.util.NLS;

public class TaskMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.publisher.ant.messages";
  public static String exception_errorOccurredCallingGenerator;
  public static String exception_errorArtifactRepo;
  public static String exception_errorMetadataRepo;
  
  static
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.p2.publisher.ant.messages", TaskMessages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.publisher.ant.TaskMessages
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1

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