Search in sources :

Example 16 with IRequirement

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

Example 17 with IRequirement

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());
            }
        }
    }
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IStatus(org.eclipse.core.runtime.IStatus) IProfileChangeRequest(org.eclipse.equinox.p2.planner.IProfileChangeRequest) IProfileChangeRequest(org.eclipse.equinox.p2.planner.IProfileChangeRequest) ProfileChangeRequest(org.eclipse.equinox.internal.p2.director.ProfileChangeRequest) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 18 with IRequirement

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

Example 19 with IRequirement

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;
}
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 20 with IRequirement

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

Aggregations

IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)31 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)23 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)11 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8 File (java.io.File)7 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)6 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)6 LinkedHashSet (java.util.LinkedHashSet)5 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)5 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)5 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)4 List (java.util.List)2 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Version (org.eclipse.equinox.p2.metadata.Version)2 FeatureEntry (org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry)2