use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class ModuleArtifactRepository method getInternalDescriptorForAdding.
@Override
protected ModuleArtifactDescriptor getInternalDescriptorForAdding(IArtifactDescriptor descriptor) throws IllegalArgumentException {
if (descriptor == null) {
throw new NullPointerException();
} else if (!(descriptor instanceof ModuleArtifactDescriptor) || descriptor.getRepository() != this) {
throw new IllegalArgumentException("Cannot add artifact descriptor which has not been created by this repository");
}
ModuleArtifactDescriptor internalDescriptor = (ModuleArtifactDescriptor) descriptor;
try {
MavenRepositoryCoordinates coordinates = internalDescriptor.getMavenCoordinates();
artifactsMap.addToAutomaticLocation(coordinates.getClassifier(), coordinates.getExtension());
} catch (ProvisionException e) {
// TODO 393004 Revise exception handling
throw new RuntimeException(e);
}
return internalDescriptor;
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class ModuleArtifactRepository method failedReadException.
static ProvisionException failedReadException(File sourceFile, String details, Exception exception) {
String message = "Error while reading repository from " + sourceFile;
if (details != null) {
message += ": " + details;
}
int code = ProvisionException.REPOSITORY_FAILED_READ;
Status status = new Status(IStatus.ERROR, BUNDLE_ID, code, message, exception);
return new ProvisionException(status);
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class MirrorApplicationServiceImpl method mirrorStandalone.
@Override
public void mirrorStandalone(RepositoryReferences sources, DestinationRepositoryDescriptor destination, Collection<IUDescription> seedIUs, MirrorOptions mirrorOptions, BuildOutputDirectory tempDirectory) throws FacadeException {
IProvisioningAgent agent = Activator.createProvisioningAgent(tempDirectory);
try {
final MirrorApplication mirrorApp = createMirrorApplication(sources, destination, agent, mirrorOptions.isIncludePacked());
mirrorApp.setSlicingOptions(createSlicingOptions(mirrorOptions));
mirrorApp.setIgnoreErrors(mirrorOptions.isIgnoreErrors());
try {
// we want to see mirror progress as this is a possibly long-running operation
mirrorApp.setVerbose(true);
mirrorApp.setLog(new LogListener(mavenContext.getLogger()));
mirrorApp.setSourceIUs(querySourceIus(seedIUs, mirrorApp.getCompositeMetadataRepository(), sources));
IStatus returnStatus = mirrorApp.run(null);
checkStatus(returnStatus, mirrorOptions.isIgnoreErrors());
} catch (ProvisionException e) {
throw new FacadeException(MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
}
} finally {
agent.stop();
}
}
use of org.eclipse.equinox.p2.core.ProvisionException 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);
}
use of org.eclipse.equinox.p2.core.ProvisionException in project tycho by eclipse.
the class DependencyCollectorTest method missingDependencies.
@Test
public void missingDependencies() {
InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
String time = Long.toString(System.currentTimeMillis());
iud.setId(time);
iud.setVersion(Version.createOSGi(0, 0, 0, time));
ArrayList<IRequirement> requirements = new ArrayList<>();
VersionRange range = new VersionRange("[1.2.3,1.2.4)");
requirements.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, "this.is.a.missing.iu", range, null, 1, /* min */
1, /* max */
true));
iud.setRequirements(requirements.toArray(new IRequirement[requirements.size()]));
HashSet<IInstallableUnit> rootUIs = new HashSet<>();
rootUIs.add(MetadataFactory.createInstallableUnit(iud));
ResolutionDataImpl data = new ResolutionDataImpl(ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS);
data.setRootIUs(rootUIs);
data.setAdditionalRequirements(new ArrayList<IRequirement>());
data.setAvailableIUs(Collections.<IInstallableUnit>emptyList());
DependencyCollector dc = new DependencyCollector(logVerifier.getLogger());
dc.setData(data);
try {
dc.resolve(Collections.<String, String>emptyMap(), new NullProgressMonitor());
Assert.fail();
} catch (RuntimeException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause instanceof ProvisionException);
ProvisionException pe = (ProvisionException) cause;
Assert.assertTrue(pe.getStatus().isMultiStatus());
MultiStatus status = (MultiStatus) pe.getStatus();
Assert.assertEquals(1, status.getChildren().length);
Assert.assertTrue(e.toString().contains("this.is.a.missing.iu"));
}
}
Aggregations