Search in sources :

Example 1 with PublisherResult

use of org.eclipse.equinox.p2.publisher.PublisherResult 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 2 with PublisherResult

use of org.eclipse.equinox.p2.publisher.PublisherResult 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 3 with PublisherResult

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

the class StandardEEResolutionHints method addIUsFromEnvironment.

static void addIUsFromEnvironment(String executionEnvironment, Map<VersionedId, IInstallableUnit> units) {
    // generate real IUs that represent requested execution environment
    PublisherResult results = new PublisherResult();
    new JREAction(executionEnvironment).perform(new PublisherInfo(), results, null);
    results.query(QueryUtil.ALL_UNITS, null);
    Iterator<IInstallableUnit> iterator = results.query(QueryUtil.ALL_UNITS, null).iterator();
    while (iterator.hasNext()) {
        put(units, iterator.next());
    }
}
Also used : PublisherInfo(org.eclipse.equinox.p2.publisher.PublisherInfo) PublisherResult(org.eclipse.equinox.p2.publisher.PublisherResult) JREAction(org.eclipse.equinox.p2.publisher.actions.JREAction) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Aggregations

PublisherResult (org.eclipse.equinox.p2.publisher.PublisherResult)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 PublisherInfo (org.eclipse.equinox.p2.publisher.PublisherInfo)2 JREAction (org.eclipse.equinox.p2.publisher.actions.JREAction)2 IStatus (org.eclipse.core.runtime.IStatus)1 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)1 Publisher (org.eclipse.equinox.p2.publisher.Publisher)1 IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)1 TransientArtifactRepository (org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository)1 Test (org.junit.Test)1