use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class AbstractSlicerResolutionStrategy method createStrictRequirementTo.
private static IRequirement createStrictRequirementTo(IInstallableUnit unit) {
VersionRange strictRange = new VersionRange(unit.getVersion(), true, unit.getVersion(), true);
int min = 1;
int max = Integer.MAX_VALUE;
boolean greedy = true;
IRequirement requirement = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, unit.getId(), strictRange, unit.getFilter(), min, max, greedy);
return requirement;
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project epp.mpc by eclipse.
the class CompositeProfileChangeOperation method updateRequest.
private void updateRequest(ProfileChangeRequest request, ProfileChangeOperation operation, MultiStatus status, IProgressMonitor monitor) {
// TODO we do too much here - this already does the plan resolution, which is expensive...
IStatus result = operation.resolveModal(monitor);
status.merge(result);
if (status.getSeverity() != IStatus.ERROR) {
IProfileChangeRequest operationChangeRequest = operation.getProfileChangeRequest();
Collection<IInstallableUnit> additions = operationChangeRequest.getAdditions();
Collection<IInstallableUnit> removals = operationChangeRequest.getRemovals();
Collection<IRequirement> extraRequirements = operationChangeRequest.getExtraRequirements();
request.removeAll(removals);
request.addAll(additions);
if (extraRequirements != null) {
request.addExtraRequirements(extraRequirements);
}
if (operationChangeRequest instanceof ProfileChangeRequest) {
ProfileChangeRequest internalRequest = (ProfileChangeRequest) operationChangeRequest;
Map<IInstallableUnit, List<String>> installableUnitProfilePropertiesToRemove = internalRequest.getInstallableUnitProfilePropertiesToRemove();
for (Entry<IInstallableUnit, List<String>> entry : installableUnitProfilePropertiesToRemove.entrySet()) {
List<String> properties = entry.getValue();
if (properties != null && !properties.isEmpty()) {
IInstallableUnit iu = entry.getKey();
for (String property : properties) {
request.removeInstallableUnitProfileProperty(iu, property);
}
}
}
Map<IInstallableUnit, Map<String, String>> installableUnitProfilePropertiesToAdd = internalRequest.getInstallableUnitProfilePropertiesToAdd();
for (Entry<IInstallableUnit, Map<String, String>> entry : installableUnitProfilePropertiesToAdd.entrySet()) {
Map<String, String> properties = entry.getValue();
if (properties != null && !properties.isEmpty()) {
IInstallableUnit iu = entry.getKey();
for (Entry<String, String> property : properties.entrySet()) {
request.setInstallableUnitProfileProperty(iu, property.getKey(), property.getValue());
}
}
}
String[] propertiesToRemove = internalRequest.getPropertiesToRemove();
for (String property : propertiesToRemove) {
request.removeProfileProperty(property);
}
Map<String, String> propertiesToAdd = internalRequest.getPropertiesToAdd();
for (Entry<String, String> property : propertiesToAdd.entrySet()) {
request.setProfileProperty(property.getKey(), property.getValue());
}
}
}
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class AbstractDependenciesAction method addRequiredCapability.
protected void addRequiredCapability(Set<IRequirement> required, String id, Version version, String filter, boolean optional) {
VersionRange range = getVersionRange(version);
required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, InstallableUnit.parseFilter(filter), optional, false));
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class AbstractSiteDependenciesAction method getRequiredCapabilities.
@Override
protected Set<IRequirement> getRequiredCapabilities() {
Set<IRequirement> required = new LinkedHashSet<>();
for (SiteFeature feature : getSiteModel().getFeatures()) {
// $NON-NLS-1$
String id = feature.getFeatureIdentifier() + FEATURE_GROUP_IU_SUFFIX;
VersionRange range = getVersionRange(createVersion(feature.getFeatureVersion()));
String filter = new TargetEnvironment(feature.getOS(), feature.getWS(), feature.getOSArch()).toFilterExpression();
// boolean optional = feature.isOptional();
required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, InstallableUnit.parseFilter(filter), false, false));
}
for (SiteBundle bundle : getSiteModel().getBundles()) {
String id = bundle.getBundleIdentifier();
VersionRange range = getVersionRange(createVersion(bundle.getBundleVersion()));
String filter = new TargetEnvironment(bundle.getOS(), bundle.getWS(), bundle.getOSArch()).toFilterExpression();
// boolean optional = feature.isOptional();
required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, InstallableUnit.parseFilter(filter), false, false));
}
for (SiteIU iu : getSiteModel().getIUs()) {
IRequirement requirement = getRequirement(iu);
if (requirement != null)
required.add(requirement);
}
return required;
}
use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.
the class P2ResolverAdditionalRequirementsTest method testExactVersionMatchInTargetDefinitionUnit.
@Test
public void testExactVersionMatchInTargetDefinitionUnit() throws Exception {
String olderVersion = "2.3.3";
String version = "2.3.4";
String newerVersion = "2.3.5";
String exactVersionMatchRange = "[" + version + "," + version + "]";
impl.addDependency(IU_TYPE, TARGET_UNIT_ID, exactVersionMatchRange);
impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, exactVersionMatchRange);
List<IRequirement> requirements = impl.getAdditionalRequirements();
IInstallableUnit matchingIU = createIU(version);
assertIUMatchesRequirements(matchingIU, requirements);
IInstallableUnit newerIU = createIU(newerVersion);
assertIUDoesNotMatchRequirements(newerIU, requirements);
IInstallableUnit olderIU = createIU(olderVersion);
assertIUDoesNotMatchRequirements(olderIU, requirements);
}
Aggregations