use of org.eclipse.equinox.p2.metadata.VersionRange in project tycho by eclipse.
the class AbstractDependenciesAction method getVersionRange.
/**
* @see org.eclipse.tycho.artifacts.DependencyArtifacts.getArtifact(String, String, String)
*/
protected VersionRange getVersionRange(Version version) {
if (version == null || OSGi_versionMin.equals(version)) {
return VersionRange.emptyRange;
}
org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(version);
String qualifier = osgiVersion.getQualifier();
if (qualifier == null || "".equals(qualifier) || ANY_QUALIFIER.equals(qualifier)) {
Version from = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro());
Version to = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro() + 1);
return new VersionRange(from, true, to, false);
}
return new VersionRange(version, true, version, true);
}
use of org.eclipse.equinox.p2.metadata.VersionRange 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;
}
use of org.eclipse.equinox.p2.metadata.VersionRange in project tycho by eclipse.
the class ArtifactMatcher method getRangeOfEquivalentVersions.
/**
* Returns a version range which includes "equivalent" versions, i.e. versions with the same
* major, minor, and micro version.
*/
private static VersionRange getRangeOfEquivalentVersions(Version version) {
Integer major = (Integer) version.getSegment(0);
Integer minor = (Integer) version.getSegment(1);
Integer micro = (Integer) version.getSegment(2);
VersionRange range = new VersionRange(Version.createOSGi(major, minor, micro), true, Version.createOSGi(major, minor, micro + 1), false);
return range;
}
use of org.eclipse.equinox.p2.metadata.VersionRange 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.VersionRange 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));
}
Aggregations