From 980ea6215eb1101d93b9b7fa32a9eecbb90059e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 3 Jun 2022 19:35:33 +0200 Subject: [PATCH] Rework the handling of profiles - do not embed any static profile - compute the java packages based on the running vm and toolchains - fall back to "higher" profiles if an exact match is not found - do not validate BREEs against static list of names - fix java 9 compatibility of ListSystemPackages --- RELEASE_NOTES.md | 10 + .../compiler/AbstractOsgiCompilerMojo.java | 3 +- ...ExecutionEnvironmentConfigurationImpl.java | 6 +- .../core/ee/ExecutionEnvironmentUtils.java | 177 +++++++++++++++--- .../tycho/core/osgitools/EquinoxResolver.java | 2 +- .../tycho/core/osgitools/OsgiManifest.java | 10 +- .../src/main/resources/JavaSE-11.profile | 32 ---- .../src/main/resources/JavaSE-14.profile | 36 ---- .../src/main/resources/JavaSE-16.profile | 38 ---- .../src/main/resources/JavaSE-17.profile | 39 ---- .../src/main/resources/JavaSE-18.profile | 40 ---- .../ee/StandardExecutionEnvironmentTest.java | 124 ++++++------ .../core/osgitools/OsgiManifestTest.java | 5 - .../extras/tpvalidator/TPValidationMojo.java | 3 +- .../test/eeProfile/Java18ResolutionTest.java | 46 ++--- .../p2/publisher/PublishOsgiEEMojo.java | 18 +- 16 files changed, 261 insertions(+), 328 deletions(-) delete mode 100644 tycho-core/src/main/resources/JavaSE-11.profile delete mode 100644 tycho-core/src/main/resources/JavaSE-14.profile delete mode 100644 tycho-core/src/main/resources/JavaSE-16.profile delete mode 100644 tycho-core/src/main/resources/JavaSE-17.profile delete mode 100644 tycho-core/src/main/resources/JavaSE-18.profile diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index cf241fbfcb..689c79c08a 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,11 @@ This page describes the noteworthy improvements provided by each release of Ecli ## 3.0.0 (under development) +### Tycho no longer ships JVM profiles + +Because of modular VMs the profiles shipped by Tycho has never been complete and actually are already partly generated in regards to available packages. +From now on, Tycho do not ship any profiles and thus you can use any VM in the toolchains or as a running VM and Tycho will generate a profile for it. + ### Enhanced Support for Maven CI Friendly Versions Starting with Maven 3.8.5 Tycho now supports an enhanced form of the [Maven CI Friendly Versions](https://maven.apache.org/maven-ci-friendly.html) beside the standard properties names one could also use: @@ -183,6 +188,11 @@ This can be useful if you like to execute the build with multiple threads (e.g. ### Migration guide 2.x -> 3.x +#### publish-osgi-ee do not publish a fixed size of profiles anymore + +The `publish-osgi-ee` previously has published a fixes list of "usefull" execution environments maintained by Tycho. +This is no longer true and Tycho do publish only those JavaSE profiles that are available to the build and have a version larger than 11 if not configured explicitly. + #### jgit-timestamp provider moved from `org.eclipse.tycho.extras` to `org.eclipse.tycho` The `tycho-buildtimestamp-jgit` plugin has moved to the `org.eclipse.tycho` group id. diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java index ea303ca989..a4083f0f40 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java @@ -392,7 +392,8 @@ public StandardExecutionEnvironment[] getBREE() { return null; } }).filter(Objects::nonNull).collect(Collectors.toList()); - manifestBREEs = ExecutionEnvironmentUtils.getProfileNames().stream() // + manifestBREEs = ExecutionEnvironmentUtils.getProfileNames(toolchainManager, session, logger) + .stream() // .map(name -> name.split("-")) // .map(segments -> Map.of(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE, segments[0], "version", segments[1])) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentConfigurationImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentConfigurationImpl.java index 246eae51ce..5c289705e7 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentConfigurationImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentConfigurationImpl.java @@ -106,7 +106,9 @@ public boolean isCustomProfile() { return false; } String profileName = getProfileName(); - boolean profileExists = ExecutionEnvironmentUtils.getProfileNames().contains(profileName); + Collection profileNames = ExecutionEnvironmentUtils.getProfileNames(toolchainManager, session, logger); + boolean profileExists = profileNames + .contains(profileName); if (!profileExists && ignoredByResolver) { throw new BuildFailureException( "When using a custom execution environment profile, resolveWithExecutionEnvironmentConstraints must not be set to false"); @@ -162,7 +164,7 @@ public boolean isIgnoredByResolver() { @Override public Collection getAllKnownEEs() { - return ExecutionEnvironmentUtils.getProfileNames().stream() // + return ExecutionEnvironmentUtils.getProfileNames(toolchainManager, session, logger).stream() // .map(profileName -> ExecutionEnvironmentUtils.getExecutionEnvironment(profileName, toolchainManager, session, logger)) // .collect(Collectors.toList()); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java index 1c896ee39d..b545957eec 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/ee/ExecutionEnvironmentUtils.java @@ -14,13 +14,12 @@ import java.io.InputStream; import java.net.URL; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashMap; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import org.apache.maven.execution.MavenSession; @@ -28,6 +27,7 @@ import org.apache.maven.toolchain.ToolchainManager; import org.codehaus.plexus.logging.Logger; import org.eclipse.osgi.internal.framework.EquinoxConfiguration; +import org.eclipse.tycho.core.ee.StandardExecutionEnvironment.JavaInfo; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment.SystemPackageEntry; import org.osgi.framework.BundleActivator; @@ -41,23 +41,7 @@ */ public class ExecutionEnvironmentUtils { - private static final Map profilesProperties = fillEnvironmentsMap(); - private static final Map executionEnvironmentsMap = new ConcurrentHashMap<>( - profilesProperties.size(), 1.f); - - private static Map fillEnvironmentsMap() { - Properties listProps = readProperties(findInSystemBundle("profile.list")); - List profileFiles = new ArrayList<>(Arrays.asList(listProps.getProperty("java.profiles").split(","))); - profileFiles.add("JavaSE-11.profile"); - profileFiles.add("JavaSE-17.profile"); - profileFiles.add("JavaSE-18.profile"); - Map envMap = new LinkedHashMap<>(profileFiles.size(), 1.f); - for (String profileFile : profileFiles) { - Properties props = readProperties(findInSystemBundle(profileFile.trim())); - envMap.put(props.getProperty(EquinoxConfiguration.PROP_OSGI_JAVA_PROFILE_NAME).trim(), props); - } - return envMap; - } + private static Map executionEnvironmentsMap; private static Properties readProperties(final URL url) { Properties listProps = new Properties(); @@ -81,20 +65,110 @@ private static Properties readProperties(final URL url) { */ public static StandardExecutionEnvironment getExecutionEnvironment(String profileName, ToolchainManager manager, MavenSession session, Logger logger) throws UnknownEnvironmentException { - if (!profilesProperties.containsKey(profileName)) { - throw new UnknownEnvironmentException(profileName); + Map map = getExecutionEnvironmentsMap(manager, session, logger); + StandardExecutionEnvironment ee = map.get(profileName); + if (ee != null) { + return ee; + } + int version = getVersion(profileName); + if (version > 8) { + //try find newer version... + StandardExecutionEnvironment higherEE = map.keySet().stream() + .mapToInt(ExecutionEnvironmentUtils::getVersion).filter(v -> v > version).min().stream() + .mapToObj(v -> { + String[] split = profileName.split("-"); + return split[0] + "-" + v; + }).map(map::get).findFirst().orElse(null); + if (higherEE != null) { + logger.warn("Using " + higherEE.getProfileName() + " to fulfill requested profile of " + profileName + + " this might lead to faulty dependency resolution, consider define a suitable VM in the toolchains."); + return higherEE; + } + } + logger.debug("Unknown OSGi execution environment, EE currently known to the build:"); + for (StandardExecutionEnvironment knownEE : map.values()) { + logger.debug(knownEE.getProfileName()); + } + throw new UnknownEnvironmentException(profileName); + } + + public static Collection getProfileNames(ToolchainManager manager, MavenSession session, Logger logger) { + + return new ArrayList<>(getExecutionEnvironmentsMap(manager, session, logger).keySet()); + } + + private static synchronized Map getExecutionEnvironmentsMap( + ToolchainManager manager, MavenSession session, Logger logger) { + if (executionEnvironmentsMap == null) { + executionEnvironmentsMap = new HashMap(); + Properties listProps = readProperties(findInSystemBundle("profile.list")); + //first read all profiles that are part of the system... + for (String profileFile : listProps.getProperty("java.profiles").split(",")) { + Properties props = readProperties(findInSystemBundle(profileFile.trim())); + if (props == null) { + logger.warn("can't read profile " + profileFile + " from system path"); + continue; + } + String name = props.getProperty(EquinoxConfiguration.PROP_OSGI_JAVA_PROFILE_NAME).trim(); + executionEnvironmentsMap.put(name, new StandardExecutionEnvironment(props, + getToolchainFor(name, manager, session, logger), logger)); + } + //derive from the toolchains... + if (manager != null) { + List jdks = manager.getToolchains(session, "jdk", null); + for (Toolchain jdk : jdks) { + JavaInfo javaInfo = StandardExecutionEnvironment.readFromToolchains(jdk, logger); + if (javaInfo.version > 8) { + Properties toolchainJvm = createProfileJvm(javaInfo.version, javaInfo.packages); + String name = toolchainJvm.getProperty(EquinoxConfiguration.PROP_OSGI_JAVA_PROFILE_NAME).trim(); + executionEnvironmentsMap.put(name, new StandardExecutionEnvironment(toolchainJvm, jdk, logger)); + } + } + } + //derive from the running jvm... + int javaVersion = Runtime.version().feature(); + if (!executionEnvironmentsMap.containsKey("JavaSE-" + javaVersion)) { + Properties runningVm = createProfileJvm(javaVersion, ListSystemPackages.getCurrentJREPackages()); + String name = runningVm.getProperty(EquinoxConfiguration.PROP_OSGI_JAVA_PROFILE_NAME).trim(); + executionEnvironmentsMap.put(name, new StandardExecutionEnvironment(runningVm, + getToolchainFor(name, manager, session, logger), logger)); + } } - return executionEnvironmentsMap.computeIfAbsent(profileName, name -> { - List toolchains = manager != null && session != null - ? manager.getToolchains(session, "jdk", Collections.singletonMap("id", profileName)) - : Collections.emptyList(); - return new StandardExecutionEnvironment(profilesProperties.get(name), - toolchains.isEmpty() ? null : toolchains.iterator().next(), logger); - }); + return executionEnvironmentsMap; } - public static List getProfileNames() { - return new ArrayList<>(profilesProperties.keySet()); + private static Toolchain getToolchainFor(String profileName, ToolchainManager manager, MavenSession session, + Logger logger) { + if (manager != null) { + logger.debug("Search profile " + profileName + " in ToolchainManager..."); + //First try to find it by ID + for (Toolchain toolchain : manager.getToolchains(session, "jdk", + Collections.singletonMap("id", profileName))) { + return toolchain; + } + //Try find by version + int version = getVersion(profileName); + if (version > 8) { + for (Toolchain toolchain : manager.getToolchains(session, "jdk", + Collections.singletonMap("version", String.valueOf(version)))) { + return toolchain; + } + } + } + return null; + } + + public static int getVersion(String profileName) { + String[] split = profileName.split("-"); + if (split.length == 2) { + try { + return (int) Double.parseDouble(split[split.length - 1]); + } catch (NumberFormatException e) { + //can't check then... + } + } + return -1; + } public static void applyProfileProperties(Properties properties, ExecutionEnvironment executionEnvironment) { @@ -137,4 +211,45 @@ private static URL findInSystemBundle(String entry) { ClassLoader loader = BundleActivator.class.getClassLoader(); return loader == null ? ClassLoader.getSystemResource(entry) : loader.getResource(entry); } + + //This is derived from org.eclipse.equinox.p2.publisher.actions.JREAction.createDefaultProfileFromRunningJvm() + private static Properties createProfileJvm(int javaVersion, Collection packages) { + String profileName = "JavaSE-" + javaVersion; + Properties props = new Properties(); + // add systempackages + props.setProperty("org.osgi.framework.system.packages", packages.stream().collect(Collectors.joining(","))); + // add EE + StringBuilder ee = new StringBuilder( + "OSGi/Minimum-1.0,OSGi/Minimum-1.1,OSGi/Minimum-1.2,JavaSE/compact1-1.8,JavaSE/compact2-1.8,JavaSE/compact3-1.8,JRE-1.1,J2SE-1.2,J2SE-1.3,J2SE-1.4,J2SE-1.5,JavaSE-1.6,JavaSE-1.7,JavaSE-1.8,"); + for (int i = 9; i < javaVersion; i++) { + ee.append("JavaSE-" + String.valueOf(i) + ","); + } + ee.append(profileName); + props.setProperty("org.osgi.framework.executionenvironment", ee.toString()); + // add capabilities + StringBuilder versionList = new StringBuilder(); + versionList.append("1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8"); + for (int i = 9; i <= javaVersion; i++) { + versionList.append(", " + String.valueOf(i) + ".0"); + } + props.setProperty("org.osgi.framework.system.capabilities", + "osgi.ee; osgi.ee=\"OSGi/Minimum\"; version:List=\"1.0, 1.1, 1.2\",osgi.ee; osgi.ee=\"JRE\"; version:List=\"1.0, 1.1\",osgi.ee; osgi.ee=\"JavaSE\"; version:List=\"" + + versionList.toString() + + "\",osgi.ee; osgi.ee=\"JavaSE/compact1\"; version:List=\"1.8," + + String.valueOf(javaVersion) + + ".0\",osgi.ee; osgi.ee=\"JavaSE/compact2\"; version:List=\"1.8," + + String.valueOf(javaVersion) + + ".0\",osgi.ee; osgi.ee=\"JavaSE/compact3\"; version:List=\"1.8," + + String.valueOf(javaVersion) + ".0\""); + + // add profile name and compiler options + props.setProperty("osgi.java.profile.name", profileName); + props.setProperty("org.eclipse.jdt.core.compiler.compliance", String.valueOf(javaVersion)); + props.setProperty("org.eclipse.jdt.core.compiler.source", String.valueOf(javaVersion)); + props.setProperty("org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode", "enabled"); + props.setProperty("org.eclipse.jdt.core.compiler.codegen.targetPlatform", String.valueOf(javaVersion)); + props.setProperty("org.eclipse.jdt.core.compiler.problem.assertIdentifier", "error"); + props.setProperty("org.eclipse.jdt.core.compiler.problem.enumIdentifier", "error"); + return props; + } } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java index cf7235306d..dc4f12c8ae 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java @@ -242,7 +242,7 @@ protected Properties getPlatformProperties(Properties properties, MavenSession m // ignoring EE by adding all known EEs StringJoiner allSystemPackages = new StringJoiner(","); StringJoiner allSystemCapabilities = new StringJoiner(","); - for (String profile : ExecutionEnvironmentUtils.getProfileNames()) { + for (String profile : ExecutionEnvironmentUtils.getProfileNames(toolchainManager, mavenSession, logger)) { StandardExecutionEnvironment executionEnvironment = ExecutionEnvironmentUtils .getExecutionEnvironment(profile, toolchainManager, mavenSession, logger); String currentSystemPackages = (String) executionEnvironment.getProfileProperties() diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java index e1e0342bc8..3ea0ab2bfd 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java @@ -13,8 +13,6 @@ import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.DefaultArtifactKey; -import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; -import org.eclipse.tycho.core.ee.UnknownEnvironmentException; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; import org.osgi.framework.Version; @@ -61,12 +59,8 @@ private String[] parseExecutionEnvironments() { } String[] envs = new String[brees.length]; for (int i = 0; i < brees.length; i++) { - String ee = brees[i].getValue(); - if (ExecutionEnvironmentUtils.getProfileNames().contains(ee)) { - envs[i] = ee; - } else { - throw new OsgiManifestParserException(location, new UnknownEnvironmentException(ee)); - } + //BREE already has no real meaning for modular vms so matching them here does not really offer much... + envs[i] = brees[i].getValue(); } return envs; } diff --git a/tycho-core/src/main/resources/JavaSE-11.profile b/tycho-core/src/main/resources/JavaSE-11.profile deleted file mode 100644 index 0fb6a92f14..0000000000 --- a/tycho-core/src/main/resources/JavaSE-11.profile +++ /dev/null @@ -1,32 +0,0 @@ -org.osgi.framework.executionenvironment = \ - OSGi/Minimum-1.0,\ - OSGi/Minimum-1.1,\ - OSGi/Minimum-1.2,\ - JavaSE/compact1-1.8,\ - JavaSE/compact2-1.8,\ - JavaSE/compact3-1.8,\ - JRE-1.1,\ - J2SE-1.2,\ - J2SE-1.3,\ - J2SE-1.4,\ - J2SE-1.5,\ - JavaSE-1.6,\ - JavaSE-1.7,\ - JavaSE-1.8,\ - JavaSE-9,\ - JavaSE-10,\ - JavaSE-11, -org.osgi.framework.system.capabilities = \ - osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2",\ - osgi.ee; osgi.ee="JRE"; version:List="1.0, 1.1",\ - osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact1"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact2"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact3"; version:List="1.8, 9.0, 10.0, 11.0" -osgi.java.profile.name = JavaSE-11 -org.eclipse.jdt.core.compiler.compliance=11 -org.eclipse.jdt.core.compiler.source=11 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/tycho-core/src/main/resources/JavaSE-14.profile b/tycho-core/src/main/resources/JavaSE-14.profile deleted file mode 100644 index 638a224f85..0000000000 --- a/tycho-core/src/main/resources/JavaSE-14.profile +++ /dev/null @@ -1,36 +0,0 @@ -# copied and adapted from JavaSE-11 -org.osgi.framework.executionenvironment = \ - OSGi/Minimum-1.0,\ - OSGi/Minimum-1.1,\ - OSGi/Minimum-1.2,\ - JavaSE/compact1-1.8,\ - JavaSE/compact2-1.8,\ - JavaSE/compact3-1.8,\ - JRE-1.1,\ - J2SE-1.2,\ - J2SE-1.3,\ - J2SE-1.4,\ - J2SE-1.5,\ - JavaSE-1.6,\ - JavaSE-1.7,\ - JavaSE-1.8,\ - JavaSE-9,\ - JavaSE-10,\ - JavaSE-11,\ - JavaSE-12,\ - JavaSE-13,\ - JavaSE-14, -org.osgi.framework.system.capabilities = \ - osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2",\ - osgi.ee; osgi.ee="JRE"; version:List="1.0, 1.1",\ - osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0",\ - osgi.ee; osgi.ee="JavaSE/compact1"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact2"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact3"; version:List="1.8, 9.0, 10.0, 11.0" -osgi.java.profile.name = JavaSE-14 -org.eclipse.jdt.core.compiler.compliance=14 -org.eclipse.jdt.core.compiler.source=14 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=14 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/tycho-core/src/main/resources/JavaSE-16.profile b/tycho-core/src/main/resources/JavaSE-16.profile deleted file mode 100644 index 6681277b1b..0000000000 --- a/tycho-core/src/main/resources/JavaSE-16.profile +++ /dev/null @@ -1,38 +0,0 @@ -# copied and adapted from JavaSE-15 -org.osgi.framework.executionenvironment = \ - OSGi/Minimum-1.0,\ - OSGi/Minimum-1.1,\ - OSGi/Minimum-1.2,\ - JavaSE/compact1-1.8,\ - JavaSE/compact2-1.8,\ - JavaSE/compact3-1.8,\ - JRE-1.1,\ - J2SE-1.2,\ - J2SE-1.3,\ - J2SE-1.4,\ - J2SE-1.5,\ - JavaSE-1.6,\ - JavaSE-1.7,\ - JavaSE-1.8,\ - JavaSE-9,\ - JavaSE-10,\ - JavaSE-11,\ - JavaSE-12,\ - JavaSE-13,\ - JavaSE-14,\ - JavaSE-15,\ - JavaSE-16, -org.osgi.framework.system.capabilities = \ - osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2",\ - osgi.ee; osgi.ee="JRE"; version:List="1.0, 1.1",\ - osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0",\ - osgi.ee; osgi.ee="JavaSE/compact1"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact2"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact3"; version:List="1.8, 9.0, 10.0, 11.0" -osgi.java.profile.name = JavaSE-16 -org.eclipse.jdt.core.compiler.compliance=16 -org.eclipse.jdt.core.compiler.source=16 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=16 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/tycho-core/src/main/resources/JavaSE-17.profile b/tycho-core/src/main/resources/JavaSE-17.profile deleted file mode 100644 index 67bdf5f079..0000000000 --- a/tycho-core/src/main/resources/JavaSE-17.profile +++ /dev/null @@ -1,39 +0,0 @@ -# copied and adapted from JavaSE-16 -org.osgi.framework.executionenvironment = \ - OSGi/Minimum-1.0,\ - OSGi/Minimum-1.1,\ - OSGi/Minimum-1.2,\ - JavaSE/compact1-1.8,\ - JavaSE/compact2-1.8,\ - JavaSE/compact3-1.8,\ - JRE-1.1,\ - J2SE-1.2,\ - J2SE-1.3,\ - J2SE-1.4,\ - J2SE-1.5,\ - JavaSE-1.6,\ - JavaSE-1.7,\ - JavaSE-1.8,\ - JavaSE-9,\ - JavaSE-10,\ - JavaSE-11,\ - JavaSE-12,\ - JavaSE-13,\ - JavaSE-14,\ - JavaSE-15,\ - JavaSE-16,\ - JavaSE-17, -org.osgi.framework.system.capabilities = \ - osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2",\ - osgi.ee; osgi.ee="JRE"; version:List="1.0, 1.1",\ - osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0",\ - osgi.ee; osgi.ee="JavaSE/compact1"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact2"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact3"; version:List="1.8, 9.0, 10.0, 11.0" -osgi.java.profile.name = JavaSE-17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.source=17 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/tycho-core/src/main/resources/JavaSE-18.profile b/tycho-core/src/main/resources/JavaSE-18.profile deleted file mode 100644 index 3d08a9aaf2..0000000000 --- a/tycho-core/src/main/resources/JavaSE-18.profile +++ /dev/null @@ -1,40 +0,0 @@ -# copied and adapted from JavaSE-17 -org.osgi.framework.executionenvironment = \ - OSGi/Minimum-1.0,\ - OSGi/Minimum-1.1,\ - OSGi/Minimum-1.2,\ - JavaSE/compact1-1.8,\ - JavaSE/compact2-1.8,\ - JavaSE/compact3-1.8,\ - JRE-1.1,\ - J2SE-1.2,\ - J2SE-1.3,\ - J2SE-1.4,\ - J2SE-1.5,\ - JavaSE-1.6,\ - JavaSE-1.7,\ - JavaSE-1.8,\ - JavaSE-9,\ - JavaSE-10,\ - JavaSE-11,\ - JavaSE-12,\ - JavaSE-13,\ - JavaSE-14,\ - JavaSE-15,\ - JavaSE-16,\ - JavaSE-17,\ - JavaSE-18, -org.osgi.framework.system.capabilities = \ - osgi.ee; osgi.ee="OSGi/Minimum"; version:List="1.0, 1.1, 1.2",\ - osgi.ee; osgi.ee="JRE"; version:List="1.0, 1.1",\ - osgi.ee; osgi.ee="JavaSE"; version:List="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0",\ - osgi.ee; osgi.ee="JavaSE/compact1"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact2"; version:List="1.8, 9.0, 10.0, 11.0",\ - osgi.ee; osgi.ee="JavaSE/compact3"; version:List="1.8, 9.0, 10.0, 11.0" -osgi.java.profile.name = JavaSE-18 -org.eclipse.jdt.core.compiler.compliance=18 -org.eclipse.jdt.core.compiler.source=18 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=18 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/ee/StandardExecutionEnvironmentTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/ee/StandardExecutionEnvironmentTest.java index 5b15b6bc98..213cd05d27 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/ee/StandardExecutionEnvironmentTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/core/ee/StandardExecutionEnvironmentTest.java @@ -27,14 +27,12 @@ public class StandardExecutionEnvironmentTest { - private StandardExecutionEnvironment javaSE18Environment; - private StandardExecutionEnvironment javaSE17Environment; - private StandardExecutionEnvironment javaSE11Environment; + private StandardExecutionEnvironment runningJavaEnvironment; private StandardExecutionEnvironment javaSE9Environment; private StandardExecutionEnvironment javaSE8Environment; - private StandardExecutionEnvironment javaSE7Enviroment; - private StandardExecutionEnvironment javaSE6Enviroment; - private StandardExecutionEnvironment j2SE5Enviroment; + private StandardExecutionEnvironment javaSE7Environment; + private StandardExecutionEnvironment javaSE6Environment; + private StandardExecutionEnvironment j2SE5Environment; private StandardExecutionEnvironment j2SE14Environment; private StandardExecutionEnvironment j2SE13Environment; private StandardExecutionEnvironment j2SE12Environment; @@ -44,32 +42,28 @@ public class StandardExecutionEnvironmentTest { private StandardExecutionEnvironment osgiMin10Environment; private StandardExecutionEnvironment osgiMin11Environment; private StandardExecutionEnvironment osgiMin12Environment; - private StandardExecutionEnvironment javaSECompact1Enviroment; - private StandardExecutionEnvironment javaSECompact2Enviroment; - private StandardExecutionEnvironment javaSECompact3Enviroment; + private StandardExecutionEnvironment javaSECompact1Environment; + private StandardExecutionEnvironment javaSECompact2Environment; + private StandardExecutionEnvironment javaSECompact3Environment; @Before public void setUp() throws Exception { - javaSECompact1Enviroment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE/compact1-1.8", null, null, + javaSECompact1Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE/compact1-1.8", null, null, new SilentLog()); - javaSECompact2Enviroment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE/compact2-1.8", null, null, + javaSECompact2Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE/compact2-1.8", null, null, new SilentLog()); - javaSECompact3Enviroment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE/compact3-1.8", null, null, - new SilentLog()); - javaSE18Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-18", null, null, - new SilentLog()); - javaSE17Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-17", null, null, - new SilentLog()); - javaSE11Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-11", null, null, + javaSECompact3Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE/compact3-1.8", null, null, new SilentLog()); + runningJavaEnvironment = ExecutionEnvironmentUtils + .getExecutionEnvironment("JavaSE-" + Runtime.version().feature(), null, null, new SilentLog()); javaSE9Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-9", null, null, new SilentLog()); javaSE8Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.8", null, null, new SilentLog()); - javaSE7Enviroment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.7", null, null, + javaSE7Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.7", null, null, new SilentLog()); - javaSE6Enviroment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.6", null, null, + javaSE6Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.6", null, null, new SilentLog()); - j2SE5Enviroment = ExecutionEnvironmentUtils.getExecutionEnvironment("J2SE-1.5", null, null, new SilentLog()); + j2SE5Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("J2SE-1.5", null, null, new SilentLog()); j2SE14Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("J2SE-1.4", null, null, new SilentLog()); j2SE13Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("J2SE-1.3", null, null, new SilentLog()); j2SE12Environment = ExecutionEnvironmentUtils.getExecutionEnvironment("J2SE-1.2", null, null, new SilentLog()); @@ -88,13 +82,12 @@ public void setUp() throws Exception { @Test public void testNotNull() { - assertNotNull(javaSE18Environment); - assertNotNull(javaSE17Environment); + assertNotNull(runningJavaEnvironment); assertNotNull(javaSE9Environment); assertNotNull(javaSE8Environment); - assertNotNull(javaSE7Enviroment); - assertNotNull(javaSE6Enviroment); - assertNotNull(j2SE5Enviroment); + assertNotNull(javaSE7Environment); + assertNotNull(javaSE6Environment); + assertNotNull(j2SE5Environment); assertNotNull(j2SE14Environment); assertNotNull(j2SE12Environment); assertNotNull(jre11Environment); @@ -103,21 +96,19 @@ public void testNotNull() { assertNotNull(osgiMin10Environment); assertNotNull(osgiMin11Environment); assertNotNull(osgiMin12Environment); - assertNotNull(javaSECompact1Enviroment); - assertNotNull(javaSECompact2Enviroment); - assertNotNull(javaSECompact3Enviroment); + assertNotNull(javaSECompact1Environment); + assertNotNull(javaSECompact2Environment); + assertNotNull(javaSECompact3Environment); } @Test public void testGetProfileName() { - assertEquals("JavaSE-18", javaSE18Environment.getProfileName()); - assertEquals("JavaSE-17", javaSE17Environment.getProfileName()); - assertEquals("JavaSE-11", javaSE11Environment.getProfileName()); + assertEquals("JavaSE-" + Runtime.version().feature(), runningJavaEnvironment.getProfileName()); assertEquals("JavaSE-9", javaSE9Environment.getProfileName()); assertEquals("JavaSE-1.8", javaSE8Environment.getProfileName()); - assertEquals("JavaSE-1.7", javaSE7Enviroment.getProfileName()); - assertEquals("JavaSE-1.6", javaSE6Enviroment.getProfileName()); - assertEquals("J2SE-1.5", j2SE5Enviroment.getProfileName()); + assertEquals("JavaSE-1.7", javaSE7Environment.getProfileName()); + assertEquals("JavaSE-1.6", javaSE6Environment.getProfileName()); + assertEquals("J2SE-1.5", j2SE5Environment.getProfileName()); assertEquals("J2SE-1.4", j2SE14Environment.getProfileName()); assertEquals("J2SE-1.3", j2SE13Environment.getProfileName()); assertEquals("J2SE-1.2", j2SE12Environment.getProfileName()); @@ -127,9 +118,9 @@ public void testGetProfileName() { assertEquals("OSGi/Minimum-1.0", osgiMin10Environment.getProfileName()); assertEquals("OSGi/Minimum-1.1", osgiMin11Environment.getProfileName()); assertEquals("OSGi/Minimum-1.2", osgiMin12Environment.getProfileName()); - assertEquals("JavaSE/compact1-1.8", javaSECompact1Enviroment.getProfileName()); - assertEquals("JavaSE/compact2-1.8", javaSECompact2Enviroment.getProfileName()); - assertEquals("JavaSE/compact3-1.8", javaSECompact3Enviroment.getProfileName()); + assertEquals("JavaSE/compact1-1.8", javaSECompact1Environment.getProfileName()); + assertEquals("JavaSE/compact2-1.8", javaSECompact2Environment.getProfileName()); + assertEquals("JavaSE/compact3-1.8", javaSECompact3Environment.getProfileName()); } @Test @@ -143,17 +134,16 @@ public void testCompilerSourceLevel() { assertEquals("1.3", j2SE12Environment.getCompilerSourceLevelDefault()); assertEquals("1.3", j2SE13Environment.getCompilerSourceLevelDefault()); assertEquals("1.3", j2SE14Environment.getCompilerSourceLevelDefault()); - assertEquals("1.5", j2SE5Enviroment.getCompilerSourceLevelDefault()); - assertEquals("1.6", javaSE6Enviroment.getCompilerSourceLevelDefault()); - assertEquals("1.7", javaSE7Enviroment.getCompilerSourceLevelDefault()); + assertEquals("1.5", j2SE5Environment.getCompilerSourceLevelDefault()); + assertEquals("1.6", javaSE6Environment.getCompilerSourceLevelDefault()); + assertEquals("1.7", javaSE7Environment.getCompilerSourceLevelDefault()); assertEquals("1.8", javaSE8Environment.getCompilerSourceLevelDefault()); assertEquals("9", javaSE9Environment.getCompilerSourceLevelDefault()); - assertEquals("11", javaSE11Environment.getCompilerSourceLevelDefault()); - assertEquals("17", javaSE17Environment.getCompilerSourceLevelDefault()); - assertEquals("18", javaSE18Environment.getCompilerSourceLevelDefault()); - assertEquals("1.8", javaSECompact1Enviroment.getCompilerSourceLevelDefault()); - assertEquals("1.8", javaSECompact2Enviroment.getCompilerSourceLevelDefault()); - assertEquals("1.8", javaSECompact3Enviroment.getCompilerSourceLevelDefault()); + assertEquals(String.valueOf(Runtime.version().feature()), + runningJavaEnvironment.getCompilerSourceLevelDefault()); + assertEquals("1.8", javaSECompact1Environment.getCompilerSourceLevelDefault()); + assertEquals("1.8", javaSECompact2Environment.getCompilerSourceLevelDefault()); + assertEquals("1.8", javaSECompact3Environment.getCompilerSourceLevelDefault()); } @Test @@ -167,17 +157,16 @@ public void testCompilerTargetLevel() { assertEquals("1.1", j2SE12Environment.getCompilerTargetLevelDefault()); assertEquals("1.1", j2SE13Environment.getCompilerTargetLevelDefault()); assertEquals("1.2", j2SE14Environment.getCompilerTargetLevelDefault()); - assertEquals("1.5", j2SE5Enviroment.getCompilerTargetLevelDefault()); - assertEquals("1.6", javaSE6Enviroment.getCompilerTargetLevelDefault()); - assertEquals("1.7", javaSE7Enviroment.getCompilerTargetLevelDefault()); + assertEquals("1.5", j2SE5Environment.getCompilerTargetLevelDefault()); + assertEquals("1.6", javaSE6Environment.getCompilerTargetLevelDefault()); + assertEquals("1.7", javaSE7Environment.getCompilerTargetLevelDefault()); assertEquals("1.8", javaSE8Environment.getCompilerTargetLevelDefault()); assertEquals("9", javaSE9Environment.getCompilerTargetLevelDefault()); - assertEquals("11", javaSE11Environment.getCompilerTargetLevelDefault()); - assertEquals("17", javaSE17Environment.getCompilerTargetLevelDefault()); - assertEquals("18", javaSE18Environment.getCompilerTargetLevelDefault()); - assertEquals("1.8", javaSECompact1Enviroment.getCompilerTargetLevelDefault()); - assertEquals("1.8", javaSECompact2Enviroment.getCompilerTargetLevelDefault()); - assertEquals("1.8", javaSECompact3Enviroment.getCompilerTargetLevelDefault()); + assertEquals(String.valueOf(Runtime.version().feature()), + runningJavaEnvironment.getCompilerTargetLevelDefault()); + assertEquals("1.8", javaSECompact1Environment.getCompilerTargetLevelDefault()); + assertEquals("1.8", javaSECompact2Environment.getCompilerTargetLevelDefault()); + assertEquals("1.8", javaSECompact3Environment.getCompilerTargetLevelDefault()); } @Test @@ -187,19 +176,18 @@ public void testCompilerTargetCompatibility() throws Exception { assertFalse(j2SE14Environment.isCompatibleCompilerTargetLevel("1.3")); // version aliases - assertTrue(j2SE5Enviroment.isCompatibleCompilerTargetLevel("5")); - assertTrue(j2SE5Enviroment.isCompatibleCompilerTargetLevel("5.0")); - assertTrue(javaSE6Enviroment.isCompatibleCompilerTargetLevel("6")); - assertTrue(javaSE6Enviroment.isCompatibleCompilerTargetLevel("6.0")); - assertTrue(javaSE7Enviroment.isCompatibleCompilerTargetLevel("7")); - assertTrue(javaSE7Enviroment.isCompatibleCompilerTargetLevel("7.0")); + assertTrue(j2SE5Environment.isCompatibleCompilerTargetLevel("5")); + assertTrue(j2SE5Environment.isCompatibleCompilerTargetLevel("5.0")); + assertTrue(javaSE6Environment.isCompatibleCompilerTargetLevel("6")); + assertTrue(javaSE6Environment.isCompatibleCompilerTargetLevel("6.0")); + assertTrue(javaSE7Environment.isCompatibleCompilerTargetLevel("7")); + assertTrue(javaSE7Environment.isCompatibleCompilerTargetLevel("7.0")); assertTrue(javaSE8Environment.isCompatibleCompilerTargetLevel("8")); assertTrue(javaSE8Environment.isCompatibleCompilerTargetLevel("8.0")); assertTrue(javaSE9Environment.isCompatibleCompilerTargetLevel("9")); assertTrue(javaSE9Environment.isCompatibleCompilerTargetLevel("9.0")); - assertTrue(javaSE11Environment.isCompatibleCompilerTargetLevel("11.0")); - assertTrue(javaSE17Environment.isCompatibleCompilerTargetLevel("17.0")); - assertTrue(javaSE18Environment.isCompatibleCompilerTargetLevel("18.0")); + assertTrue(runningJavaEnvironment + .isCompatibleCompilerTargetLevel(String.valueOf(Runtime.version().feature()) + ".0")); } @Test(expected = UnknownEnvironmentException.class) @@ -211,9 +199,9 @@ public void testUnknownEnv() throws Throwable { public void testCompare() throws Exception { List expectedList = new ArrayList<>(Arrays.asList(osgiMin10Environment, osgiMin11Environment, osgiMin12Environment, cdc10Environment, cdc11Environment, jre11Environment, - j2SE12Environment, j2SE13Environment, j2SE14Environment, j2SE5Enviroment, javaSE6Enviroment, - javaSE7Enviroment, javaSECompact1Enviroment, javaSECompact2Enviroment, javaSECompact3Enviroment, - javaSE8Environment, javaSE9Environment, javaSE11Environment, javaSE17Environment, javaSE18Environment)); + j2SE12Environment, j2SE13Environment, j2SE14Environment, j2SE5Environment, javaSE6Environment, + javaSE7Environment, javaSECompact1Environment, javaSECompact2Environment, javaSECompact3Environment, + javaSE8Environment, javaSE9Environment, runningJavaEnvironment)); List actualList = new ArrayList<>(expectedList); Collections.shuffle(actualList); Collections.sort(actualList); diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/OsgiManifestTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/OsgiManifestTest.java index f6852e5175..2ef9d5b5d7 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/OsgiManifestTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/OsgiManifestTest.java @@ -110,11 +110,6 @@ public void testNoBREE() throws Exception { assertArrayEquals(new String[0], manifest.getExecutionEnvironments()); } - @Test(expected = OsgiManifestParserException.class) - public void testInvalidBREE() throws Exception { - parseManifest("invalidBree.mf"); - } - private OsgiManifest parseManifest(String manifestName) throws URISyntaxException { InputStream stream = getClass().getResourceAsStream("/manifests/" + manifestName); return OsgiManifest.parse(stream, "testLocation"); diff --git a/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java b/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java index 11558ce352..8fd68e3180 100644 --- a/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java +++ b/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java @@ -238,7 +238,8 @@ public String getProfileName() { @Override public boolean isCustomProfile() { - return !ExecutionEnvironmentUtils.getProfileNames().contains(ee.getProfileName()); + return !ExecutionEnvironmentUtils.getProfileNames(toolchainManager, session, logger) + .contains(ee.getProfileName()); } @Override diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/eeProfile/Java18ResolutionTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/eeProfile/Java18ResolutionTest.java index 8a0c946b0c..079a89a892 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/eeProfile/Java18ResolutionTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/eeProfile/Java18ResolutionTest.java @@ -22,31 +22,33 @@ import org.eclipse.tycho.test.AbstractTychoIntegrationTest; import org.eclipse.tycho.test.util.P2RepositoryTool; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; +@Ignore("unless java 18 jvm is aviable to tycho build") public class Java18ResolutionTest extends AbstractTychoIntegrationTest { - private static File buildResult; - - @BeforeClass - public static void setUp() throws Exception { - buildResult = new Java18ResolutionTest().runBuild(); - } - - public File runBuild() throws Exception { - Verifier verifier = getVerifier("eeProfile.java18", false); - verifier.executeGoal("verify"); - verifier.verifyErrorFreeLog(); - return new File(verifier.getBasedir()); - } - - @Test - public void testProductBuildForJava17() throws Exception { - // a p2 repository that contains a product for Java 18 - P2RepositoryTool productRepo = P2RepositoryTool.forEclipseRepositoryModule(new File(buildResult, "repository")); - List jreUnitVersions = productRepo.getUnitVersions("a.jre.javase"); - // we expect java 18 - assertThat(jreUnitVersions, hasItem("18.0.0")); - } + private static File buildResult; + + @BeforeClass + public static void setUp() throws Exception { + buildResult = new Java18ResolutionTest().runBuild(); + } + + public File runBuild() throws Exception { + Verifier verifier = getVerifier("eeProfile.java18", false); + verifier.executeGoal("verify"); + verifier.verifyErrorFreeLog(); + return new File(verifier.getBasedir()); + } + + @Test + public void testProductBuildForJava18() throws Exception { + // a p2 repository that contains a product for Java 18 + P2RepositoryTool productRepo = P2RepositoryTool.forEclipseRepositoryModule(new File(buildResult, "repository")); + List jreUnitVersions = productRepo.getUnitVersions("a.jre.javase"); + // we expect java 18 + assertThat(jreUnitVersions, hasItem("18.0.0")); + } } diff --git a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishOsgiEEMojo.java b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishOsgiEEMojo.java index f2cb86e521..6b3595ae81 100644 --- a/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishOsgiEEMojo.java +++ b/tycho-p2/tycho-p2-publisher-plugin/src/main/java/org/eclipse/tycho/plugins/p2/publisher/PublishOsgiEEMojo.java @@ -13,8 +13,10 @@ package org.eclipse.tycho.plugins.p2.publisher; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.stream.Collectors; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -47,11 +49,10 @@ public final class PublishOsgiEEMojo extends AbstractPublishMojo { * Comma-separated list of profile names to be published. Examples: JavaSE-11, JavaSE-17, * JavaSE-18. * - * It is advised to keep this list as small as possible and the list must include the BREE used - * by the platform, last Java LTS and the latest Java release. + * If not given, all current available JavaSE profiles with version >= 11 are used. *

*/ - @Parameter(defaultValue = "JavaSE-11, JavaSE-17, JavaSE-18") + @Parameter private String profiles; @Parameter(defaultValue = "false") @@ -72,7 +73,7 @@ protected Collection publishContent(PublisherServiceFactory publ PublisherService publisherService = publisherServiceFactory.createPublisher(getReactorProject(), getEnvironments()); Collection result = new ArrayList<>(); - for (String profile : profiles.split(",")) { + for (String profile : getProfilesForPublish()) { try { profile = profile.trim(); if (profile.isEmpty()) { @@ -92,4 +93,13 @@ protected Collection publishContent(PublisherServiceFactory publ return result; } + private Iterable getProfilesForPublish() { + if (profiles != null && !profiles.isEmpty()) { + return Arrays.asList(profiles.split(",")); + } + return ExecutionEnvironmentUtils.getProfileNames(toolchainManager, getSession(), logger).stream() + .filter(str -> str.startsWith("JavaSE-")) + .filter(profile -> ExecutionEnvironmentUtils.getVersion(profile) >= 11).collect(Collectors.toList()); + } + }