Search in sources :

Example 11 with InstallableUnitDescription

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;
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) Version(org.eclipse.equinox.p2.metadata.Version) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 12 with InstallableUnitDescription

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

Example 13 with InstallableUnitDescription

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;
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 14 with InstallableUnitDescription

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) MetadataParser(org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser)

Example 15 with InstallableUnitDescription

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());
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) Test(org.junit.Test)

Aggregations

InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)19 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)9 ArrayList (java.util.ArrayList)6 File (java.io.File)4 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)4 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)4 Test (org.junit.Test)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 LinkedHashSet (java.util.LinkedHashSet)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 ArtifactKey (org.eclipse.equinox.internal.p2.metadata.ArtifactKey)2 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)2 Version (org.eclipse.equinox.p2.metadata.Version)2 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)2 BufferedInputStream (java.io.BufferedInputStream)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1