Search in sources :

Example 6 with IPublisherInfo

use of org.eclipse.equinox.p2.publisher.IPublisherInfo in project tycho by eclipse.

the class AbstractDependenciesAction method perform.

@Override
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
    InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
    iud.setId(getId());
    iud.setVersion(getVersion());
    Set<IProvidedCapability> provided = new LinkedHashSet<>();
    addProvidedCapabilities(provided);
    provided.add(MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, iud.getId(), iud.getVersion()));
    iud.addProvidedCapabilities(provided);
    iud.addRequirements(getRequiredCapabilities());
    addProperties(iud);
    addPublisherAdvice(publisherInfo);
    processCapabilityAdvice(iud, publisherInfo);
    processInstallableUnitPropertiesAdvice(iud, publisherInfo);
    IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
    results.addIU(iu, PublisherResult.ROOT);
    InstallableUnitDescription[] others = processAdditionalInstallableUnitsAdvice(iu, publisherInfo);
    if (others != null) {
        for (InstallableUnitDescription other : others) {
            // using PublisherResult.NON_ROOT results in these IUs appear after the primary
            // see org.eclipse.equinox.p2.publisher.PublisherResult.getIUs(String, String)
            // see org.eclipse.tycho.p2.metadata.IReactorArtifactFacade.getDependencyMetadata()
            results.addIU(MetadataFactory.createInstallableUnit(other), PublisherResult.NON_ROOT);
        }
    }
    return Status.OK_STATUS;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 7 with IPublisherInfo

use of org.eclipse.equinox.p2.publisher.IPublisherInfo in project tycho by eclipse.

the class FeatureDependenciesAction method addPublisherAdvice.

@Override
protected void addPublisherAdvice(IPublisherInfo publisherInfo) {
    // see org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction.createAdviceFileAdvice(Feature, IPublisherInfo)
    IPath location = new Path(feature.getLocation());
    Version version = Version.parseVersion(feature.getVersion());
    String groupId = getId();
    AdviceFileAdvice advice = new AdviceFileAdvice(groupId, version, location, new Path("p2.inf"));
    if (advice.containsAdvice()) {
        publisherInfo.addAdvice(advice);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Version(org.eclipse.equinox.p2.metadata.Version) AdviceFileAdvice(org.eclipse.equinox.p2.publisher.AdviceFileAdvice)

Example 8 with IPublisherInfo

use of org.eclipse.equinox.p2.publisher.IPublisherInfo in project tycho by eclipse.

the class ProductDependenciesAction method addPublisherAdvice.

@Override
protected void addPublisherAdvice(IPublisherInfo publisherInfo) {
    // see org.eclipse.equinox.p2.publisher.eclipse.ProductAction.createAdviceFileAdvice()
    File productFileLocation = product.getLocation();
    if (productFileLocation == null) {
        return;
    }
    String id = product.getId();
    Version parseVersion = Version.parseVersion(product.getVersion());
    IPath basePath = new Path(productFileLocation.getParent());
    // must match org.eclipse.tycho.plugins.p2.publisher.PublishProductMojo.getSourceP2InfFile(File)
    final String productFileName = productFileLocation.getName();
    final String p2infFilename = productFileName.substring(0, productFileName.length() - ".product".length()) + ".p2.inf";
    AdviceFileAdvice advice = new AdviceFileAdvice(id, parseVersion, basePath, new Path(p2infFilename));
    if (advice.containsAdvice()) {
        publisherInfo.addAdvice(advice);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Version(org.eclipse.equinox.p2.metadata.Version) ProductFile(org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile) File(java.io.File) AdviceFileAdvice(org.eclipse.equinox.p2.publisher.AdviceFileAdvice)

Example 9 with IPublisherInfo

use of org.eclipse.equinox.p2.publisher.IPublisherInfo in project tycho by eclipse.

the class PublisherActionRunner method executeAction.

public Collection<IInstallableUnit> executeAction(IPublisherAction action, IMetadataRepository metadataOutput, IArtifactRepository artifactOutput, IPublisherAdvice... advice) {
    ResultSpyAction resultSpy = new ResultSpyAction();
    IPublisherAction[] actions = new IPublisherAction[] { action, resultSpy };
    /**
     * The PublisherInfo must not be cached, or results may leak between publishing actions (see
     * bug 346532).
     */
    IPublisherInfo publisherInfo = newPublisherInfo(metadataOutput, artifactOutput);
    for (IPublisherAdvice adviceItem : advice) {
        publisherInfo.addAdvice(adviceItem);
    }
    Publisher publisher = new Publisher(publisherInfo);
    IStatus result = publisher.publish(actions, null);
    handlePublisherStatus(result);
    return resultSpy.getAllIUs();
}
Also used : IPublisherAdvice(org.eclipse.equinox.p2.publisher.IPublisherAdvice) IStatus(org.eclipse.core.runtime.IStatus) IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) Publisher(org.eclipse.equinox.p2.publisher.Publisher) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo)

Aggregations

File (java.io.File)3 IStatus (org.eclipse.core.runtime.IStatus)3 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)3 Version (org.eclipse.equinox.p2.metadata.Version)3 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 Status (org.eclipse.core.runtime.Status)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)2 AdviceFileAdvice (org.eclipse.equinox.p2.publisher.AdviceFileAdvice)2 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)2 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1