From d9f36d2055fa674bcda8c744ca7b9cff22a6f3f3 Mon Sep 17 00:00:00 2001 From: Ed Merks Date: Sat, 30 Mar 2024 14:36:24 +0100 Subject: [PATCH] TargetPlatformFactoryImpl.gatherP2InfUnits should use artifact version Currently the implementation hard codes the version to 1.0.0 when parsing advice from a p2.inf. This can result in an IAE if the version is used in a range such as [1.0.0,$version$) where because [1.0.0,1.0.0) is not a valid range. Instead use the reactor project's actual version. --- .../p2resolver/TargetPlatformFactoryImpl.java | 19 +++++++++++++++++-- .../bundle/META-INF/MANIFEST.MF | 2 +- .../p2Inf.virtualUnit/bundle/META-INF/p2.inf | 12 +++++++++--- .../projects/p2Inf.virtualUnit/bundle/pom.xml | 2 +- tycho-its/projects/p2Inf.virtualUnit/pom.xml | 2 +- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java index 0ae6282857..8818eb0e24 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java @@ -122,6 +122,8 @@ public class TargetPlatformFactoryImpl implements TargetPlatformFactory { + private static final Version DEFAULT_P2_ADVICE_VERSION = Version.parseVersion("1.0.0.qualifier"); + private final MavenContext mavenContext; private final MavenLogger logger; private final IProgressMonitor monitor; @@ -304,12 +306,13 @@ private void gatherP2InfUnits(ReactorProject reactorProject, Set Version.parseVersion(key.getVersion())) + .orElseGet(() -> DEFAULT_P2_ADVICE_VERSION); + } catch (IllegalArgumentException ex) { + return DEFAULT_P2_ADVICE_VERSION; + } + } + private List getMissingJunitBundles(ReactorProject project, Set externalUIs) { List missing = new ArrayList<>(); if (projectManager != null) { diff --git a/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/MANIFEST.MF b/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/MANIFEST.MF index e84277d955..8ab2fac223 100644 --- a/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/MANIFEST.MF +++ b/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: pvu.bundle Bundle-SymbolicName: pvu.bundle;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 2.0.0.qualifier Bundle-Vendor: TEST Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/p2.inf b/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/p2.inf index 36434565aa..8bcb129162 100644 --- a/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/p2.inf +++ b/tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/p2.inf @@ -1,11 +1,17 @@ # Create the virtual IU units.0.id=configure.pvu.bundle -units.0.version=1.0.0 +units.0.version=$version$ units.0.provides.1.namespace=org.eclipse.equinox.p2.iu units.0.provides.1.name=configure.pvu.bundle -units.0.provides.1.version=1.0.0 +units.0.provides.1.version=$version$ # Require in this bundle the created virtual IU requires.0.namespace=org.eclipse.equinox.p2.iu requires.0.name=configure.pvu.bundle -requires.0.range=0.0.0 +requires.0.range=$version$ + +# Specify update advice with a version range that is invalid if $version$ expands to 1.0.0 +# For this example it should expand to 2.0.0 +update.id = update.pvu.bundle +update.range = [1.0.0,$version$) +update.severity = 0 diff --git a/tycho-its/projects/p2Inf.virtualUnit/bundle/pom.xml b/tycho-its/projects/p2Inf.virtualUnit/bundle/pom.xml index 2a785844bf..3cd507c0ce 100644 --- a/tycho-its/projects/p2Inf.virtualUnit/bundle/pom.xml +++ b/tycho-its/projects/p2Inf.virtualUnit/bundle/pom.xml @@ -7,7 +7,7 @@ tycho-its-project.p2Inf.virtualUnit parent - 1.0.0-SNAPSHOT + 2.0.0-SNAPSHOT pvu.bundle diff --git a/tycho-its/projects/p2Inf.virtualUnit/pom.xml b/tycho-its/projects/p2Inf.virtualUnit/pom.xml index a8ceaabba6..ba1fdc122a 100644 --- a/tycho-its/projects/p2Inf.virtualUnit/pom.xml +++ b/tycho-its/projects/p2Inf.virtualUnit/pom.xml @@ -6,7 +6,7 @@ tycho-its-project.p2Inf.virtualUnit parent - 1.0.0-SNAPSHOT + 2.0.0-SNAPSHOT pom