Search in sources :

Example 6 with PublisherInfo

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

the class SiteDependenciesAction method perform.

@Override
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
    try {
        // don't need transport to read local site.xml
        Transport transport = null;
        updateSite = UpdateSite.load(location.toURI(), transport, monitor);
    } catch (ProvisionException e) {
        return new Status(IStatus.ERROR, Activator.ID, "Error generating site xml action.", e);
    }
    return super.perform(publisherInfo, results, monitor);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) Transport(org.eclipse.equinox.internal.p2.repository.Transport)

Example 7 with PublisherInfo

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

the class AbstractMetadataGenerator method publish.

private DependencyMetadata publish(PublisherInfo publisherInfo, List<IPublisherAction> actions) {
    PublisherResult result = new PublisherResult();
    Publisher publisher = new Publisher(publisherInfo, result);
    IStatus status = publisher.publish(actions.toArray(new IPublisherAction[actions.size()]), monitor);
    if (!status.isOK()) {
        throw new RuntimeException(StatusTool.collectProblems(status), status.getException());
    }
    DependencyMetadata metadata = new DependencyMetadata();
    metadata.setMetadata(true, result.getIUs(null, PublisherResult.ROOT));
    metadata.setMetadata(false, result.getIUs(null, PublisherResult.NON_ROOT));
    IArtifactRepository artifactRepository = publisherInfo.getArtifactRepository();
    if (artifactRepository instanceof TransientArtifactRepository) {
        metadata.setArtifacts(((TransientArtifactRepository) artifactRepository).getArtifactDescriptors());
    }
    return metadata;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) PublisherResult(org.eclipse.equinox.p2.publisher.PublisherResult) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Publisher(org.eclipse.equinox.p2.publisher.Publisher) TransientArtifactRepository(org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository)

Example 8 with PublisherInfo

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

the class SourcesBundleDependencyMetadataGenerator method getPublisherActions.

@Override
protected List<IPublisherAction> getPublisherActions(IArtifactFacade artifact, List<TargetEnvironment> environments, OptionalResolutionAction optionalAction) {
    ArrayList<IPublisherAction> actions = new ArrayList<>();
    String id = artifact.getArtifactId();
    String version = toCanonicalVersion(artifact.getVersion());
    try {
        // generated source bundle is not available at this point in filesystem yet, need to create
        // in-memory BundleDescription instead
        Dictionary<String, String> manifest = new Hashtable<>();
        manifest.put("Manifest-Version", "1.0");
        manifest.put("Bundle-ManifestVersion", "2");
        String sourceBundleSymbolicName = id + ".source";
        manifest.put("Bundle-SymbolicName", sourceBundleSymbolicName);
        manifest.put("Bundle-Version", version);
        manifest.put("Eclipse-SourceBundle", id + ";version=" + version + ";roots:=\".\"");
        StateObjectFactory factory = StateObjectFactory.defaultFactory;
        BundleDescription bundleDescription = factory.createBundleDescription(factory.createState(false), manifest, artifact.getLocation().getAbsolutePath(), createId(sourceBundleSymbolicName, version));
        bundleDescription.setUserObject(manifest);
        actions.add(new BundlesAction(new BundleDescription[] { bundleDescription }) {

            @Override
            protected void createAdviceFileAdvice(BundleDescription bundleDescription, IPublisherInfo publisherInfo) {
            // 367255 p2.inf is not applicable to sources bundles
            }
        });
    } catch (BundleException e) {
        throw new RuntimeException(e);
    }
    return actions;
}
Also used : IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) BundlesAction(org.eclipse.equinox.p2.publisher.eclipse.BundlesAction) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ArrayList(java.util.ArrayList) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo) StateObjectFactory(org.eclipse.osgi.service.resolver.StateObjectFactory) BundleException(org.osgi.framework.BundleException)

Example 9 with PublisherInfo

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

the class CustomEEResolutionHintsTest method testConsistencyWithJREAction.

@Test
public void testConsistencyWithJREAction() throws Exception {
    JREAction jreAction = new JREAction(resourceFile("profiles/TestMe-1.8.profile"));
    PublisherResult results = new PublisherResult();
    jreAction.perform(new PublisherInfo(), results, null);
    Set<IInstallableUnit> publishedUnits = results.query(QueryUtil.ALL_UNITS, null).toUnmodifiableSet();
    subject = new CustomEEResolutionHints("TestMe-1.8");
    for (IInstallableUnit unit : publishedUnits) {
        if (subject.isEESpecificationUnit(unit)) {
            // success: we find the unit create by the JREAction
            return;
        }
    }
    fail("'a.jre' unit for profile 'TestMe-1.8' not found in" + publishedUnits);
}
Also used : PublisherInfo(org.eclipse.equinox.p2.publisher.PublisherInfo) JREAction(org.eclipse.equinox.p2.publisher.actions.JREAction) PublisherResult(org.eclipse.equinox.p2.publisher.PublisherResult) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 10 with PublisherInfo

use of org.eclipse.equinox.p2.publisher.PublisherInfo 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)

Aggregations

PublisherInfo (org.eclipse.equinox.p2.publisher.PublisherInfo)6 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)4 File (java.io.File)3 IStatus (org.eclipse.core.runtime.IStatus)3 Version (org.eclipse.equinox.p2.metadata.Version)3 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)3 PublisherResult (org.eclipse.equinox.p2.publisher.PublisherResult)3 TransientArtifactRepository (org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository)3 LinkedHashMap (java.util.LinkedHashMap)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)2 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)2 AdviceFileAdvice (org.eclipse.equinox.p2.publisher.AdviceFileAdvice)2 Publisher (org.eclipse.equinox.p2.publisher.Publisher)2 JREAction (org.eclipse.equinox.p2.publisher.actions.JREAction)2 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1