use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class TargetPlatformFactoryImpl method createTargetPlatform.
/**
* Computes the target platform from the given configuration and content.
*
* <p>
* Used as entry point for tests, which can provide the execution environment configuration via
* the more low-level type {@link ExecutionEnvironmentResolutionHandler}.
* </p>
*
* @param tpConfiguration
* @param eeResolutionHandler
* Representation of the target execution environment profile. In case of a custom EE
* profile, the handler also reads the full specification from the target platform.
* @param reactorProjects
* may be <code>null</code>
* @param pomDependencies
* may be <code>null</code>
*
* @see #createTargetPlatform(TargetPlatformConfigurationStub,
* ExecutionEnvironmentConfiguration, List, PomDependencyCollector)
*/
public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentResolutionHandler eeResolutionHandler, List<ReactorProject> reactorProjects, PomDependencyCollector pomDependencies) {
List<TargetDefinitionContent> targetFileContent = resolveTargetDefinitions(tpConfiguration, eeResolutionHandler.getResolutionHints());
PomDependencyCollectorImpl pomDependenciesContent = (PomDependencyCollectorImpl) pomDependencies;
// TODO 412416 remove when the RepositoryBlackboardKey registration is gone
if (pomDependenciesContent == null)
pomDependenciesContent = new PomDependencyCollectorImpl(mavenContext);
// TODO 372780 get rid of this special handling of pomDependency artifacts: there should be one p2 artifact repo view on the target platform
IRawArtifactFileProvider pomDependencyArtifactRepo = pomDependenciesContent.getArtifactRepoOfPublishedBundles();
RepositoryBlackboardKey blackboardKey = RepositoryBlackboardKey.forResolutionContextArtifacts(pomDependenciesContent.getProjectLocation());
ArtifactRepositoryBlackboard.putRepository(blackboardKey, new ProviderOnlyArtifactRepository(pomDependencyArtifactRepo, Activator.getProvisioningAgent(), blackboardKey.toURI()));
logger.debug("Registered artifact repository " + blackboardKey);
Set<MavenRepositoryLocation> completeRepositories = tpConfiguration.getP2Repositories();
registerRepositoryIDs(completeRepositories);
// collect & process metadata
boolean includeLocalMavenRepo = shouldIncludeLocallyInstalledUnits(tpConfiguration);
LinkedHashSet<IInstallableUnit> externalUIs = gatherExternalInstallableUnits(completeRepositories, targetFileContent, pomDependenciesContent, includeLocalMavenRepo);
Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(reactorProjects);
List<TargetPlatformFilter> iuFilters = tpConfiguration.getFilters();
TargetPlatformFilterEvaluator filter = !iuFilters.isEmpty() ? new TargetPlatformFilterEvaluator(iuFilters, logger) : null;
applyConfiguredFilter(filter, reactorProjectUIs.keySet());
applyFilters(filter, externalUIs, reactorProjectUIs.keySet(), eeResolutionHandler.getResolutionHints());
PreliminaryTargetPlatformImpl targetPlatform = new //
PreliminaryTargetPlatformImpl(//
reactorProjectUIs, //
externalUIs, //
pomDependenciesContent.getMavenInstallableUnits(), //
eeResolutionHandler.getResolutionHints(), //
filter, //
localMetadataRepository, createExternalArtifactProvider(completeRepositories, targetFileContent, pomDependencyArtifactRepo, //
tpConfiguration.getIncludePackedArtifacts()), //
localArtifactRepository, //
includeLocalMavenRepo, logger);
eeResolutionHandler.readFullSpecification(targetPlatform.getInstallableUnits());
return targetPlatform;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class TargetPlatformFactoryImpl method applyFilters.
private void applyFilters(TargetPlatformFilterEvaluator filter, Collection<IInstallableUnit> collectionToModify, Set<IInstallableUnit> reactorProjectUIs, ExecutionEnvironmentResolutionHints eeResolutionHints) {
Set<String> reactorIUIDs = new HashSet<>();
for (IInstallableUnit unit : reactorProjectUIs) {
reactorIUIDs.add(unit.getId());
}
// a.jre/config.a.jre installable units
// partial installable units
// installable units shadowed by reactor projects
Iterator<IInstallableUnit> iter = collectionToModify.iterator();
while (iter.hasNext()) {
IInstallableUnit unit = iter.next();
if (eeResolutionHints.isNonApplicableEEUnit(unit) || isPartialIU(unit) || reactorIUIDs.contains(unit.getId())) {
// TODO debug log output?
iter.remove();
continue;
}
}
applyConfiguredFilter(filter, collectionToModify);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class TargetPlatformFactoryImpl method createTargetPlatformWithUpdatedReactorUnits.
P2TargetPlatform createTargetPlatformWithUpdatedReactorUnits(PreliminaryTargetPlatformImpl preliminaryTP, Map<IInstallableUnit, ReactorProjectIdentities> reactorUnitsMap, List<IRawArtifactFileProvider> reactorArtifacts) {
LinkedHashSet<IInstallableUnit> allUnits = preliminaryTP.getExternalUnits();
// external units are already filtered, only reactor units need to be filtered again
if (reactorUnitsMap != null) {
Collection<IInstallableUnit> reactorUnits = new LinkedList<>(reactorUnitsMap.keySet());
TargetPlatformFilterEvaluator configuredFilters = preliminaryTP.getFilter();
if (configuredFilters != null) {
configuredFilters.filterUnits(reactorUnits);
}
allUnits.addAll(reactorUnits);
}
IRawArtifactFileProvider jointArtifacts = createJointArtifactProvider(reactorArtifacts, preliminaryTP.getExternalArtifacts());
return new FinalTargetPlatformImpl(allUnits, preliminaryTP.getEEResolutionHints(), jointArtifacts, localArtifactRepository, preliminaryTP.getOriginalMavenArtifactMap(), reactorUnitsMap);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class CustomEEResolutionHandler method readCapabilities.
private List<SystemCapability> readCapabilities(IInstallableUnit specificationUnit) {
List<SystemCapability> result = new ArrayList<>();
for (IProvidedCapability capability : specificationUnit.getProvidedCapabilities()) {
String namespace = capability.getNamespace();
String name = capability.getName();
String version = capability.getVersion().toString();
if (JREAction.NAMESPACE_OSGI_EE.equals(namespace)) {
result.add(new SystemCapability(Type.OSGI_EE, name, version));
} else if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(namespace)) {
result.add(new SystemCapability(Type.JAVA_PACKAGE, name, version));
} else {
// ignore
}
}
return result;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project tycho by eclipse.
the class AuthoredIUAction method perform.
@Override
@SuppressWarnings("deprecation")
public IStatus perform(IPublisherInfo info, IPublisherResult results, IProgressMonitor monitor) {
File iuFile = new File(iuProject, "p2iu.xml");
if (!iuFile.exists())
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not find the p2iu.xml file in folder " + iuProject);
try {
FileInputStream is = new FileInputStream(iuFile);
InstallableUnitDescription iuDescriptions = new MetadataIO().readOneIU(is);
tweakIU(iuDescriptions);
Set<IInstallableUnit> ius = toIUs(iuDescriptions);
results.addIUs(ius, IPublisherResult.ROOT);
IArtifactRepository repo = info.getArtifactRepository();
boolean artifactReferenced = false;
if (repo != null) {
for (IInstallableUnit iu : ius) {
Collection<IArtifactKey> associatedKeys = iu.getArtifacts();
for (IArtifactKey key : associatedKeys) {
ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, key, null);
processArtifactPropertiesAdvice(iu, ad, info);
ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
ad.setProperty(RepositoryLayoutHelper.PROP_EXTENSION, "zip");
repo.addDescriptor(ad);
artifactReferenced = true;
}
}
}
// and fails in many places. I tried to change the code where the failures were occurring but did not succeed.
if (!artifactReferenced && repo != null) {
IInstallableUnit iu = ((IInstallableUnit) ius.iterator().next());
ArtifactDescriptor ad = (ArtifactDescriptor) PublisherHelper.createArtifactDescriptor(info, new ArtifactKey("binary", "generated_" + iu.getId(), iu.getVersion()), null);
processArtifactPropertiesAdvice(iu, ad, info);
ad.setProperty(IArtifactDescriptor.DOWNLOAD_CONTENTTYPE, IArtifactDescriptor.TYPE_ZIP);
repo.addDescriptor(ad);
artifactReferenced = true;
}
return Status.OK_STATUS;
} catch (IOException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error while reading " + iuFile, e);
}
}
Aggregations