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