use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class ModuleArtifactRepositoryTest method testLoadRepositoryWithMissingGAVProperties.
@Test(expected = ProvisionException.class)
public void testLoadRepositoryWithMissingGAVProperties() throws Exception {
// repository with a missing groupId in one of the descriptors -> loading should fail
File corruptRepository = ResourceUtil.resourceFile("repositories/module/missingGAV/target");
generateDefaultRepositoryArtifacts(corruptRepository);
try {
subject = (ModuleArtifactRepository) loadRepositoryViaAgent(corruptRepository);
} catch (ProvisionException e) {
assertThat(e.getStatus().getCode(), is(ProvisionException.REPOSITORY_FAILED_READ));
assertThat(e.getStatus().getMessage(), containsString("Error while reading repository"));
assertThat(e.getStatus().getMessage(), containsString("Maven coordinate properties are missing"));
throw e;
}
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class PublishingRepositoryTest method insertTestArtifact.
private static void insertTestArtifact(PublishingRepository publishingRepo) throws ProvisionException, IOException {
IArtifactRepository writableArtifactRepo = publishingRepo.getArtifactRepositoryForWriting(AttachedTestArtifact.getWriteSessionForArtifact());
OutputStream outputStream = writableArtifactRepo.getOutputStream(writableArtifactRepo.createArtifactDescriptor(AttachedTestArtifact.key));
writeAndClose(outputStream, AttachedTestArtifact.size);
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class SimpleArtifactRepositoryIO method read.
/**
* Reads the artifact repository from the given stream, and returns the contained array of
* abstract artifact repositories.
*
* This method performs buffering, and closes the stream when finished.
*/
public IArtifactRepository read(URL location, InputStream input, IProgressMonitor monitor) throws ProvisionException {
BufferedInputStream bufferedInput = null;
try {
try {
bufferedInput = new BufferedInputStream(input);
Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID);
repositoryParser.parse(input);
IStatus result = repositoryParser.getStatus();
switch(result.getSeverity()) {
case IStatus.CANCEL:
throw new OperationCanceledException();
case IStatus.ERROR:
throw new ProvisionException(result);
case IStatus.WARNING:
case IStatus.INFO:
LogHelper.log(result);
break;
case IStatus.OK:
break;
default:
// $NON-NLS-1$
throw new IllegalStateException("Unknown serverity value: " + result.getSeverity());
}
SimpleArtifactRepository repository = repositoryParser.getRepository();
if (repository == null)
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, Messages.io_parseError, null));
return repository;
} finally {
if (bufferedInput != null)
bufferedInput.close();
}
} catch (IOException ioe) {
String msg = NLS.bind(Messages.io_failedRead, location);
throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, ProvisionException.REPOSITORY_FAILED_READ, msg, ioe));
}
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class PackedFormatMirroringArtifactProvider method downloadMostSpecificNeededFormatOfArtifact.
@Override
protected IStatus downloadMostSpecificNeededFormatOfArtifact(IArtifactKey key) throws ProvisionException, ArtifactSinkException {
IArtifactDescriptor[] allDescriptors = remoteProviders.getArtifactDescriptors(key);
IArtifactDescriptor packedDescriptor = findPackedDescriptor(allDescriptors);
if (packedDescriptor != null) {
// TODO 393004 remove "maven-groupId", etc. properties to force storage as p2/osgi/bundle...
return downloadRawArtifact(packedDescriptor);
} else {
logger.debug("No remote repository provides " + key.getId() + "_" + key.getVersion() + " in packed format. Only the canonical format will be available in the build.");
return downloadCanonicalArtifact(key);
}
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class LocalArtifactRepositoryFactoryTest method testLoad.
@Test
public void testLoad() throws ProvisionException {
LocalArtifactRepository repo = new LocalArtifactRepository(localRepoIndices);
repo.save();
IArtifactRepository repo2 = subject.load(baseDir.toURI(), 0, new NullProgressMonitor());
Assert.assertEquals(repo, repo2);
}
Aggregations