use of org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription in project tycho by eclipse.
the class P2ResolverAdditionalRequirementsTest method createIU.
private static IInstallableUnit createIU(String version) {
InstallableUnitDescription iud = new InstallableUnitDescription();
iud.setId(TARGET_UNIT_ID);
Version osgiVersion = Version.create(version);
iud.setVersion(osgiVersion);
List<IProvidedCapability> list = new ArrayList<>();
list.add(MetadataFactory.createProvidedCapability(IU_NAMESPACE, TARGET_UNIT_ID, osgiVersion));
list.add(MetadataFactory.createProvidedCapability(BUNDLE_NAMESPACE, TARGET_UNIT_ID, osgiVersion));
iud.addProvidedCapabilities(list);
IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
return iu;
}
use of org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription in project tycho by eclipse.
the class FeatureDependenciesAction method addProperties.
@Override
protected void addProperties(InstallableUnitDescription iud) {
iud.setProperty(QueryUtil.PROP_TYPE_GROUP, "true");
StringBuilder includedIUs = new StringBuilder();
for (FeatureEntry entry : feature.getEntries()) {
String id = getInstallableUnitId(entry);
if (includedIUs.length() > 0) {
includedIUs.append(',');
}
includedIUs.append(id);
}
iud.setProperty(INCLUDED_IUS, includedIUs.toString());
}
use of org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription in project tycho by eclipse.
the class ModuleMetadataRepositoryTest method createIUs.
private static List<IInstallableUnit> createIUs(IVersionedId... unitIds) {
List<IInstallableUnit> result = new ArrayList<>();
for (IVersionedId unitId : unitIds) {
InstallableUnitDescription iuDescr = new InstallableUnitDescription();
iuDescr.setId(unitId.getId());
iuDescr.setVersion(unitId.getVersion());
result.add(MetadataFactory.createInstallableUnit(iuDescr));
}
return result;
}
use of org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription in project tycho by eclipse.
the class MetadataIO method readXML.
public Set<IInstallableUnit> readXML(InputStream is) throws IOException {
Parser parser = new Parser(Parser.PARSER_MODE.REPO);
parser.parse(is, new NullProgressMonitor());
Set<IInstallableUnit> units = new LinkedHashSet<>();
for (InstallableUnitDescription desc : parser.getUnits()) {
units.add(MetadataFactory.createInstallableUnit(desc));
}
return units;
}
use of org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription in project tycho by eclipse.
the class LocalMetadataRepositoryTest method addInstallableUnit.
@Test
public void addInstallableUnit() throws CoreException {
File location = new File("target/metadataRepo");
LocalMetadataRepository repository = createRepository(location);
InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
iud.setId("test");
iud.setVersion(Version.parseVersion("1.0.0"));
iud.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
iud.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact");
iud.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
InstallableUnitDescription iud2 = new MetadataFactory.InstallableUnitDescription();
iud2.setId("test2");
iud2.setVersion(Version.parseVersion("1.0.0"));
iud2.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
iud2.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact2");
iud2.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
IInstallableUnit iu2 = MetadataFactory.createInstallableUnit(iud2);
repository.addInstallableUnits(Arrays.asList(iu, iu2));
repository = (LocalMetadataRepository) loadRepository(location);
IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.ALL_UNITS, monitor);
ArrayList<IInstallableUnit> allius = new ArrayList<>(result.toSet());
Assert.assertEquals(2, allius.size());
// as of e3.5.2 Collector uses HashSet internally and does not guarantee collected results order
// 3.6 IQueryResult, too, is backed by HashSet. makes no sense.
// Assert.assertEquals( iu.getId(), allius.get( 0 ).getId() );
Set<IInstallableUnit> ius = repository.getGAVs().get(RepositoryLayoutHelper.getGAV(iu.getProperties()));
Assert.assertEquals(1, ius.size());
}
Aggregations