Skip to content

Commit

Permalink
Make additional P2 units from p2.inf available to the target-platform
Browse files Browse the repository at this point in the history
Currently units from p2.inf are not published to the target-platform
what can fail resolving when these are referenced in the project.

This publishes these units into the target-platform state of the
project.

Fix eclipse-tycho#2977
  • Loading branch information
laeubi committed Nov 3, 2023
1 parent e6ab82c commit 1f5e135
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@
import org.codehaus.plexus.logging.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.publisher.AdviceFileAdvice;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
Expand All @@ -68,6 +70,7 @@
import org.eclipse.tycho.IRepositoryIdManager;
import org.eclipse.tycho.MavenArtifactKey;
import org.eclipse.tycho.MavenRepositoryLocation;
import org.eclipse.tycho.PackagingType;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.ReactorProjectIdentities;
import org.eclipse.tycho.ResolvedArtifactKey;
Expand Down Expand Up @@ -261,6 +264,8 @@ public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpC
return Optional.empty();
}).ifPresent(externalUIs::add);
}
//add p2.inf items...
gatherP2InfUnits(project, externalUIs);

Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(
reactorProjects);
Expand Down Expand Up @@ -291,6 +296,31 @@ public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpC
return targetPlatform;
}

private void gatherP2InfUnits(ReactorProject reactorProject, Set<IInstallableUnit> externalUIs) {
if (reactorProject == null) {
return;
}
AdviceFileAdvice advice;
if (PackagingType.TYPE_ECLIPSE_PLUGIN.equals(reactorProject.getPackaging())) {
advice = new AdviceFileAdvice(reactorProject.getArtifactId(), Version.parseVersion("1.0.0"),
new Path(reactorProject.getBasedir().getAbsolutePath()), AdviceFileAdvice.BUNDLE_ADVICE_FILE);
} else if (PackagingType.TYPE_ECLIPSE_FEATURE.equals(reactorProject.getPackaging())) {
advice = new AdviceFileAdvice(reactorProject.getArtifactId(), Version.parseVersion("1.0.0"),
new Path(reactorProject.getBasedir().getAbsolutePath()), new Path("p2.inf"));
} else {
//not a project with advice...
return;
}
if (advice.containsAdvice()) {
InstallableUnitDescription[] descriptions = advice.getAdditionalInstallableUnitDescriptions(null);
if (descriptions != null && descriptions.length > 0) {
for (InstallableUnitDescription desc : descriptions) {
externalUIs.add(MetadataFactory.createInstallableUnit(desc));
}
}
}
}

private List<MavenArtifactKey> getMissingJunitBundles(ReactorProject project, Set<IInstallableUnit> externalUIs) {
List<MavenArtifactKey> missing = new ArrayList<>();
if (projectManager != null) {
Expand Down

0 comments on commit 1f5e135

Please sign in to comment.