Search in sources :

Example 11 with VersionRange

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;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) SiteIU(org.eclipse.equinox.internal.p2.updatesite.SiteIU) SiteFeature(org.eclipse.equinox.internal.p2.updatesite.SiteFeature) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange) SiteBundle(org.eclipse.equinox.internal.p2.updatesite.SiteBundle) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment)

Example 12 with VersionRange

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

Example 13 with VersionRange

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

Example 14 with VersionRange

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

Example 15 with VersionRange

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

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