Search in sources :

Example 36 with IInstallableUnit

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

the class InstallableUnitUtil method createBundleIU.

public static IInstallableUnit createBundleIU(String bundleId, String version) {
    InstallableUnitDescription description = createIuDescription(bundleId, version);
    description.addProvidedCapabilities(createProvidedCapability(BUNDLE_CAPABILITY_NS, bundleId, version));
    return MetadataFactory.createInstallableUnit(description);
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)

Example 37 with IInstallableUnit

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

the class ModuleMetadataRepositoryTest method unitsIn.

private static List<IVersionedId> unitsIn(IMetadataRepository repo) {
    IQueryResult<IInstallableUnit> units = repo.query(QueryUtil.ALL_UNITS, null);
    List<IVersionedId> unitIds = new ArrayList<>();
    for (Iterator<IInstallableUnit> unitIterator = units.iterator(); unitIterator.hasNext(); ) {
        IInstallableUnit unit = unitIterator.next();
        VersionedId unitId = new VersionedId(unit.getId(), unit.getVersion());
        unitIds.add(unitId);
    }
    return unitIds;
}
Also used : IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) VersionedId(org.eclipse.equinox.p2.metadata.VersionedId) IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 38 with IInstallableUnit

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

the class AbstractMavenMetadataRepository method load.

protected void load() {
    MetadataIO io = new MetadataIO();
    for (GAV gav : metadataIndex.getProjectGAVs()) {
        try {
            File localArtifactFileLocation = contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_METADATA, RepositoryLayoutHelper.EXTENSION_P2_METADATA);
            if (!localArtifactFileLocation.exists()) {
                // if files have been manually removed from the repository, simply remove them from the index (bug 351080)
                metadataIndex.removeGav(gav);
            } else {
                InputStream is = new FileInputStream(localArtifactFileLocation);
                try {
                    Set<IInstallableUnit> gavUnits = io.readXML(is);
                    unitsMap.put(gav, gavUnits);
                    units.addAll(gavUnits);
                } finally {
                    is.close();
                }
            }
        } catch (IOException e) {
            // TODO throw properly typed exception if repository cannot be loaded
            e.printStackTrace();
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IOException(java.io.IOException) GAV(org.eclipse.tycho.p2.repository.GAV) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 39 with IInstallableUnit

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

the class PreliminaryTargetPlatformImpl method reportUsedLocalIUs.

@Override
public void reportUsedLocalIUs(Collection<IInstallableUnit> usedUnits) {
    if (!includeLocalRepo) {
        return;
    }
    final Set<IInstallableUnit> localIUs = localMetadataRepository.query(QueryUtil.ALL_UNITS, null).toSet();
    localIUs.retainAll(usedUnits);
    // workaround to avoid warnings for "a.jre.javase" IUs - TODO avoid this step?
    for (Iterator<IInstallableUnit> iterator = localIUs.iterator(); iterator.hasNext(); ) {
        if (executionEnvironment.isNonApplicableEEUnit(iterator.next())) {
            iterator.remove();
        }
    }
    if (!localIUs.isEmpty()) {
        logger.warn("The following locally built units have been used to resolve project dependencies:");
        for (IInstallableUnit localIu : localIUs) {
            logger.warn("  " + localIu.getId() + "/" + localIu.getVersion());
        }
    }
}
Also used : IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 40 with IInstallableUnit

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

the class TargetPlatformFactoryImpl method getPreliminaryReactorProjectUIs.

private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorProjectUIs(List<ReactorProject> reactorProjects) throws DuplicateReactorIUsException {
    if (reactorProjects == null) {
        return Collections.emptyMap();
    }
    Map<IInstallableUnit, ReactorProjectIdentities> reactorUIs = new HashMap<>();
    Map<IInstallableUnit, Set<File>> duplicateReactorUIs = new HashMap<>();
    for (ReactorProject project : reactorProjects) {
        @SuppressWarnings("unchecked") Set<IInstallableUnit> projectIUs = (Set<IInstallableUnit>) project.getDependencyMetadata();
        if (projectIUs == null)
            continue;
        for (IInstallableUnit iu : projectIUs) {
            ReactorProjectIdentities otherOrigin = reactorUIs.put(iu, project.getIdentities());
            if (otherOrigin != null && !otherOrigin.equals(project.getIdentities())) {
                Set<File> duplicateLocations = duplicateReactorUIs.get(iu);
                if (duplicateLocations == null) {
                    duplicateLocations = new LinkedHashSet<>();
                    duplicateReactorUIs.put(iu, duplicateLocations);
                }
                duplicateLocations.add(otherOrigin.getBasedir());
                duplicateLocations.add(project.getBasedir());
            }
        }
    }
    if (!duplicateReactorUIs.isEmpty()) {
        // TODO 392320 we should only fail if IUs with same id and version but different content are found
        throw new DuplicateReactorIUsException(duplicateReactorUIs);
    }
    return reactorUIs;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ReactorProject(org.eclipse.tycho.ReactorProject) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)153 Test (org.junit.Test)58 ArrayList (java.util.ArrayList)44 File (java.io.File)38 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)25 HashSet (java.util.HashSet)18 IStatus (org.eclipse.core.runtime.IStatus)18 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)16 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)15 HashMap (java.util.HashMap)13 LinkedHashSet (java.util.LinkedHashSet)11 CoreException (org.eclipse.core.runtime.CoreException)11 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)11 ResourceUtil.resourceFile (org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile)11 URI (java.net.URI)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 SubMonitor (org.eclipse.core.runtime.SubMonitor)9 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)9 Status (org.eclipse.core.runtime.Status)8 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8