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));
}
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()));
}
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;
}
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;
}
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();
}
Aggregations