use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class BundleDependenciesAction method addRequireBundleRequirement.
@Override
protected void addRequireBundleRequirement(ArrayList<IRequirement> reqsDeps, BundleSpecification requiredBundle, ManifestElement[] rawRequireBundleHeader) {
if (optionalAction == OptionalResolutionAction.OPTIONAL) {
super.addRequireBundleRequirement(reqsDeps, requiredBundle, rawRequireBundleHeader);
return;
}
VersionRange versionRange = PublisherHelper.fromOSGiVersionRange(requiredBundle.getVersionRange());
final boolean required = !requiredBundle.isOptional() || optionalAction == OptionalResolutionAction.REQUIRE;
if (required) {
reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, requiredBundle.getName(), versionRange, null, 1, 1, true));
}
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class ProductDependenciesAction method getRequiredCapabilities.
@Override
protected Set<IRequirement> getRequiredCapabilities() {
Set<IRequirement> required = new LinkedHashSet<>();
if (product.useFeatures()) {
for (IVersionedId feature : product.getFeatures()) {
// $NON-NLS-1$
String id = feature.getId() + FEATURE_GROUP_IU_SUFFIX;
Version version = feature.getVersion();
addRequiredCapability(required, id, version, null, false);
}
} else {
for (FeatureEntry plugin : ((ProductFile) product).getProductEntries()) {
addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, true);
}
}
if (product.includeLaunchers()) {
addRequiredCapability(required, "org.eclipse.equinox.executable.feature.group", null, null, false);
}
return required;
}
use of org.eclipse.equinox.p2.metadata.IRequirement 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"));
}
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class AbstractMetadataGenerator method extractExtraEntriesAsIURequirement.
private IRequirement[] extractExtraEntriesAsIURequirement(File location) {
BuildProperties buildProps = buildPropertiesParser.parse(location);
ArrayList<IRequirement> result = new ArrayList<>();
for (Entry<String, List<String>> entry : buildProps.getJarToExtraClasspathMap().entrySet()) {
createRequirementFromExtraClasspathProperty(result, entry.getValue());
}
createRequirementFromExtraClasspathProperty(result, buildProps.getJarsExtraClasspath());
if (result.isEmpty())
return null;
return result.toArray(new IRequirement[result.size()]);
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class AbstractSiteDependenciesAction method getRequirement.
// This is roughly inspired from org.eclipse.equinox.internal.p2.updatesite.SiteXMLAction
private IRequirement getRequirement(SiteIU iu) {
String id = iu.getID();
String range = iu.getRange();
String type = iu.getQueryType();
String expression = iu.getQueryExpression();
String[] params = iu.getQueryParams();
if (id != null) {
VersionRange vRange = new VersionRange(range);
return MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, vRange, null, false, false);
} else if ("match".equals(type)) {
IMatchExpression<IInstallableUnit> iuMatcher = ExpressionUtil.getFactory().<IInstallableUnit>matchExpression(ExpressionUtil.parse(expression), params);
return MetadataFactory.createRequirement(iuMatcher, null, 0, 1, true);
} else if ("context".equals(type)) {
throw new IllegalStateException("Context iu queries are not supported in Tycho. Faulty expression is " + expression);
}
return null;
}
Aggregations