Search in sources :

Example 26 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class LocalArtifactRepositoryP2APITest method testReWriteArtifactFails.

@Test
public void testReWriteArtifactFails() throws Exception {
    // LocalArtifactRepository doesn't allow overwrites -> this may be different in other IArtifactRepository implementations
    ProvisionException expectedException = null;
    try {
        IArtifactSink addSink = subject.newAddingArtifactSink(ARTIFACT_A_KEY);
        addSink.beginWrite();
        addSink.commitWrite();
    } catch (ProvisionException e) {
        expectedException = e;
    }
    assertThat(expectedException, is(instanceOf(ProvisionException.class)));
    assertThat(expectedException.getStatus().getCode(), is(ProvisionException.ARTIFACT_EXISTS));
}
Also used : ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IArtifactSink(org.eclipse.tycho.repository.p2base.artifact.provider.streaming.IArtifactSink) Test(org.junit.Test)

Example 27 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class RepositoryArtifactProviderTest method testGetArtifactWithInfiniteMirrorFailures.

@Test
public void testGetArtifactWithInfiniteMirrorFailures() throws Exception {
    IArtifactRepository failingMirrorsRepository = createArtifactRepositoryMock();
    when(failingMirrorsRepository.contains(BUNDLE_A_KEY)).thenReturn(true);
    when(failingMirrorsRepository.getArtifactDescriptors(BUNDLE_A_KEY)).thenReturn(new IArtifactDescriptor[] { canonicalDescriptorFor(BUNDLE_A_KEY) });
    when(failingMirrorsRepository.getArtifact(argThat(is(canonicalDescriptorFor(BUNDLE_A_KEY))), any(OutputStream.class), any(IProgressMonitor.class))).thenReturn(errorWithRetry("mirror failure"));
    subject = new RepositoryArtifactProvider(Collections.singletonList(failingMirrorsRepository), TRANSFER_POLICY);
    testSink = newArtifactSinkFor(BUNDLE_A_KEY);
    // should give up if all mirrors fail
    status = subject.getArtifact(testSink, null);
    assertThat(status, is(errorStatus()));
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) OutputStream(java.io.OutputStream) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Test(org.junit.Test)

Example 28 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class MirrorApplication method initializeDestination.

@Override
protected IArtifactRepository initializeDestination(RepositoryDescriptor toInit, IArtifactRepositoryManager mgr) throws ProvisionException {
    IArtifactRepository result = super.initializeDestination(toInit, mgr);
    // simple.SimpleArtifactRepository.PUBLISH_PACK_FILES_AS_SIBLINGS is not public
    result.setProperty("publishPackFilesAsSiblings", "true");
    return result;
}
Also used : IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)

Example 29 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class PublishProductToolImpl method publishProduct.

@Override
public List<DependencySeed> publishProduct(File productFile, File launcherBinaries, String flavor) throws IllegalArgumentException {
    IProductDescriptor originalProduct = loadProductFile(productFile);
    ExpandedProduct expandedProduct = new ExpandedProduct(originalProduct, buildQualifier, targetPlatform, interpolator, logger);
    IPublisherAdvice[] advice = getProductSpecificAdviceFileAdvice(productFile, expandedProduct);
    ProductAction action = new ProductAction(null, expandedProduct, flavor, launcherBinaries);
    IMetadataRepository metadataRepository = publishingRepository.getMetadataRepository();
    IArtifactRepository artifactRepository = publishingRepository.getArtifactRepositoryForWriting(new ProductBinariesWriteSession(expandedProduct.getId()));
    Collection<IInstallableUnit> allIUs = publisherRunner.executeAction(action, metadataRepository, artifactRepository, advice);
    List<DependencySeed> seeds = new ArrayList<>();
    seeds.add(createSeed(ArtifactType.TYPE_ECLIPSE_PRODUCT, selectUnit(allIUs, expandedProduct.getId())));
    addRootFeatures(expandedProduct, seeds);
    return seeds;
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) IProductDescriptor(org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor) ArrayList(java.util.ArrayList) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) ProductAction(org.eclipse.equinox.p2.publisher.eclipse.ProductAction) IPublisherAdvice(org.eclipse.equinox.p2.publisher.IPublisherAdvice) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Example 30 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository 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

IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)23 Test (org.junit.Test)11 IStatus (org.eclipse.core.runtime.IStatus)7 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)6 File (java.io.File)4 OutputStream (java.io.OutputStream)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)3 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)3 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)2 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)2 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)2 Publisher (org.eclipse.equinox.p2.publisher.Publisher)2