Search in sources :

Example 1 with IMatchExpression

use of org.eclipse.equinox.p2.metadata.expression.IMatchExpression in project webtools.servertools by eclipse.

the class ExtensionUpdateSite method getInstallableUnits.

// Get the list of InstallableUnits and all its requirements
protected List<IServerExtension> getInstallableUnits(IMetadataRepository repo, IQuery<IInstallableUnit> query, URI url, IProgressMonitor monitor) {
    List<IServerExtension> list = new ArrayList<IServerExtension>();
    IQueryResult<IInstallableUnit> collector = repo.query(query, monitor);
    for (IInstallableUnit iu : collector.toUnmodifiableSet()) {
        Collection<IRequirement> req = iu.getRequirements();
        if (req != null) {
            for (IRequirement requirement : req) {
                IMatchExpression<IInstallableUnit> matches = requirement.getMatches();
                query = new ExpressionMatchQuery<IInstallableUnit>(IInstallableUnit.class, matches);
                IQueryResult<IInstallableUnit> collector2 = repo.query(query, monitor);
                Iterator<IInstallableUnit> iter2 = collector2.iterator();
                while (iter2.hasNext()) {
                    IInstallableUnit iu2 = iter2.next();
                    if (!list.contains(iu2)) {
                        Extension ext = new Extension(iu2, url);
                        list.add(ext);
                    }
                }
            }
        }
    }
    return list;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 2 with IMatchExpression

use of org.eclipse.equinox.p2.metadata.expression.IMatchExpression 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 3 with IMatchExpression

use of org.eclipse.equinox.p2.metadata.expression.IMatchExpression in project tycho by eclipse.

the class P2DependencyGeneratorImplTest method feature.

@Test
public void feature() throws Exception {
    generateDependencies("feature", PackagingType.TYPE_ECLIPSE_FEATURE);
    // no feature.jar IU because dependencyOnly=true
    assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    assertEquals("org.eclipse.tycho.p2.impl.test.feature.feature.group", unit.getId());
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    assertEquals(DEFAULT_CLASSIFIER, unit.getProperty(RepositoryLayoutHelper.PROP_CLASSIFIER));
    List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
    assertEquals(6, requirements.size());
    IRequiredCapability capability = getRequiredCapability("another.required.feature.feature.group", requirements);
    IMatchExpression<IInstallableUnit> matches = capability.getMatches();
    assertEquals("providedCapabilities.exists(x | x.name == $0 && x.namespace == $1 && x.version >= $2 && x.version < $3)", matches.toString());
    assertEquals(Version.parseVersion("1.0.0"), matches.getParameters()[2]);
    assertEquals(Version.parseVersion("2.0.0"), matches.getParameters()[3]);
    assertEquals(0, artifacts.size());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)2 ArrayList (java.util.ArrayList)1 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)1 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)1 IMatchExpression (org.eclipse.equinox.p2.metadata.expression.IMatchExpression)1 Test (org.junit.Test)1