From ba4bbf32f60a663f9035a88a95974b4ca95b03b8 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Mon, 12 Feb 2024 16:21:34 +0100 Subject: [PATCH] UpdateSitePublisher -addJREIU argument doesn't add current JVM Don't hard code "default" JRE version if we "guess one" and create some profile based on current JRE packages. Just read & use the version from the running JRE. Fixes https://github.com/eclipse-equinox/p2/issues/461 --- .../eclipse/equinox/p2/publisher/actions/JREAction.java | 7 +++++-- .../equinox/p2/tests/publisher/actions/JREActionTest.java | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java index a210bc5566..269276d92e 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java @@ -40,9 +40,12 @@ import org.osgi.framework.*; public class JREAction extends AbstractPublisherAction { + + private static final int RUNTIME_VERSION = Runtime.version().feature(); + private static final String DEFAULT_JRE_NAME = "a.jre"; //$NON-NLS-1$ - private static final Version DEFAULT_JRE_VERSION = Version.parseVersion("17.0"); //$NON-NLS-1$ - private static final String DEFAULT_PROFILE = "JavaSE-17"; //$NON-NLS-1$ + private static final Version DEFAULT_JRE_VERSION = Version.parseVersion(RUNTIME_VERSION + ".0"); //$NON-NLS-1$ + private static final String DEFAULT_PROFILE = "JavaSE-" + RUNTIME_VERSION; //$NON-NLS-1$ private static final String PROFILE_LOCATION = "jre.action.profile.location"; //$NON-NLS-1$ private static final String PROFILE_NAME = "osgi.java.profile.name"; //$NON-NLS-1$ private static final String PROFILE_TARGET_VERSION = "org.eclipse.jdt.core.compiler.codegen.targetPlatform"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java index 8a884af21a..1ad496c65f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java @@ -36,7 +36,6 @@ import java.util.HashMap; import java.util.Map; import java.util.zip.ZipInputStream; - import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; @@ -146,9 +145,9 @@ public void testPackageVersionsFromJavaProfile() throws Exception { @Test public void testDefaultJavaProfile() throws Exception { performAction(new JREAction((String) null)); - + int runtimeVersion = Runtime.version().feature(); // these assertions need to be changed each time the default java profile, hardcoded in o.e.e.p2.publisher.actions.JREAction, is changed; - verifyMetadataIU("a.jre.javase", 226, 23, Version.parseVersion("17.0.0")); + verifyMetadataIU("a.jre.javase", 226, 23, Version.parseVersion(runtimeVersion + ".0.0")); // verifyConfigIU(DEFAULT_JRE_NAME, DEFAULT_JRE_VERSION); // TODO config IU is not needed!? }