use of org.eclipse.equinox.p2.metadata.VersionRange 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.VersionRange in project tycho by eclipse.
the class FeatureDependenciesAction method getRequiredCapabilities.
@Override
protected Set<IRequirement> getRequiredCapabilities() {
Set<IRequirement> required = new LinkedHashSet<>();
if (feature.getLicenseFeature() != null) {
String id = feature.getLicenseFeature() + FEATURE_GROUP_IU_SUFFIX;
VersionRange range = getVersionRange(createVersion(feature.getLicenseFeatureVersion()));
required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, null, false, /* optional */
false));
}
for (FeatureEntry entry : feature.getEntries()) {
if (entry.isPatch()) {
// target platform
continue;
}
VersionRange range;
if (entry.isRequires()) {
range = getVersionRange(entry);
} else {
range = getVersionRange(createVersion(entry.getVersion()));
}
String id = getInstallableUnitId(entry);
// TODO 391283 without enhancement 391283, additional filters will always evaluate to false -> ignore for now
boolean optional = entry.isOptional();
required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, createFilter(entry), optional, false));
}
return required;
}
use of org.eclipse.equinox.p2.metadata.VersionRange in project tycho by eclipse.
the class P2ResolverImpl method addDependency.
@Override
public void addDependency(String type, String id, String versionRange) throws IllegalArtifactReferenceException {
final VersionRange parsedVersionRange;
try {
parsedVersionRange = new VersionRange(versionRange);
} catch (IllegalArgumentException e) {
throw new IllegalArtifactReferenceException("The string \"" + versionRange + "\" is not a valid OSGi version range");
}
additionalRequirements.add(ArtifactTypeHelper.createRequirementFor(type, id, parsedVersionRange));
}
use of org.eclipse.equinox.p2.metadata.VersionRange in project tycho by eclipse.
the class P2ResolverImpl method resolveInstallableUnit.
// TODO 412416 this should be a method on the class TargetPlatform
@Override
public P2ResolutionResult resolveInstallableUnit(TargetPlatform targetPlatform, String id, String versionRange) {
setContext(targetPlatform, null);
QueryableCollection queriable = new QueryableCollection(context.getInstallableUnits());
VersionRange range = new VersionRange(versionRange);
IRequirement requirement = MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, null, 1, /* min */
Integer.MAX_VALUE, /* max */
false);
IQueryResult<IInstallableUnit> result = queriable.query(QueryUtil.createLatestQuery(QueryUtil.createMatchQuery(requirement.getMatches())), monitor);
Set<IInstallableUnit> newState = result.toUnmodifiableSet();
return toResolutionResult(newState, null);
}
use of org.eclipse.equinox.p2.metadata.VersionRange in project tycho by eclipse.
the class ArtifactMatcher method resolveReference.
public static IInstallableUnit resolveReference(String type, String id, Version version, LinkedHashSet<IInstallableUnit> candidateUnits) throws IllegalArtifactReferenceException {
if (id == null) {
throw new IllegalArtifactReferenceException("ID is required");
}
VersionRange versionRange = getVersionRangeFromReference(version);
IQuery<IInstallableUnit> query = QueryUtil.createLatestQuery(ArtifactTypeHelper.createQueryFor(type, id, versionRange));
IQueryResult<IInstallableUnit> matchingIUs = query.perform(candidateUnits.iterator());
if (matchingIUs.isEmpty()) {
return null;
} else {
return matchingIUs.iterator().next();
}
}
Aggregations