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;
}
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;
}
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());
}
Aggregations