From af851639d020639fdea5625cdd3fcfb914ebdbc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 29 Dec 2024 08:54:08 +0100 Subject: [PATCH] Only apply a better profile if allowed Currently a configured profile is unconditionally replaced by a better one of the current JVM, but this is wrong if not explicitly allowed by the configuration. This is now changed, to be only used if ignoring the BREE is actually enabled. --- .../ExecutionEnvironmentConfiguration.java | 4 ++++ .../core/osgitools/OsgiBundleProject.java | 24 +++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tycho-api/src/main/java/org/eclipse/tycho/ExecutionEnvironmentConfiguration.java b/tycho-api/src/main/java/org/eclipse/tycho/ExecutionEnvironmentConfiguration.java index 29fe205e7f..43dd04ce03 100644 --- a/tycho-api/src/main/java/org/eclipse/tycho/ExecutionEnvironmentConfiguration.java +++ b/tycho-api/src/main/java/org/eclipse/tycho/ExecutionEnvironmentConfiguration.java @@ -86,6 +86,10 @@ public void setFullSpecificationForCustomProfile(List systemCa public boolean isIgnoredByResolver(); + default boolean isResolveWithEEConstraints() { + return !isIgnoredByResolver(); + } + /** * @return all known Execution Environments accessible for the same scope */ diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java index 25658ea171..e4b2531f19 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java @@ -560,18 +560,22 @@ private void applyBestOfCurrentOrConfiguredProfile(String configuredProfileName, MavenSession mavenSession, ExecutionEnvironmentConfiguration sink) { StandardExecutionEnvironment configuredProfile = ExecutionEnvironmentUtils .getExecutionEnvironment(configuredProfileName, toolchainManager, mavenSession, logger); - if (configuredProfile != null) { - // non standard profile, stick to it - sink.setProfileConfiguration(configuredProfileName, reason); + if (configuredProfile == null) { + //should never be the case as Tycho delegates to other profiles, but if we need to stick to the defaults... + return; } - StandardExecutionEnvironment currentProfile = ExecutionEnvironmentUtils.getExecutionEnvironment( - "JavaSE-" + Runtime.version().feature(), toolchainManager, mavenSession, logger); - if (currentProfile.compareTo(configuredProfile) > 0) { - sink.setProfileConfiguration(currentProfile.getProfileName(), - "Currently running profile, newer than configured profile (" + configuredProfileName + ") from [" - + reason + "]"); - } else { + if (sink.isResolveWithEEConstraints()) { sink.setProfileConfiguration(configuredProfileName, reason); + } else { + StandardExecutionEnvironment currentProfile = ExecutionEnvironmentUtils.getExecutionEnvironment( + "JavaSE-" + Runtime.version().feature(), toolchainManager, mavenSession, logger); + if (currentProfile != null && currentProfile.compareTo(configuredProfile) > 0) { + sink.setProfileConfiguration(currentProfile.getProfileName(), + "Currently running profile, newer than configured profile (" + configuredProfileName + + ") from [" + reason + "]"); + } else { + sink.setProfileConfiguration(configuredProfileName, reason); + } } }