Search in sources :

Example 6 with VersionRange

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);
}
Also used : Version(org.eclipse.equinox.p2.metadata.Version) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 7 with VersionRange

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;
}
Also used : VersionRange(org.eclipse.equinox.p2.metadata.VersionRange) IMatchExpression(org.eclipse.equinox.p2.metadata.expression.IMatchExpression)

Example 8 with VersionRange

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;
}
Also used : VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 9 with VersionRange

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;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 10 with VersionRange

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));
}
Also used : VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Aggregations

VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)16 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)7 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 Version (org.eclipse.equinox.p2.metadata.Version)3 LinkedHashSet (java.util.LinkedHashSet)2 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)2 IllegalArtifactReferenceException (org.eclipse.tycho.artifacts.IllegalArtifactReferenceException)2 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 RequiredCapability (org.eclipse.equinox.internal.p2.metadata.RequiredCapability)1