Skip to content

Commit

Permalink
Only apply a better profile if allowed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laeubi committed Dec 22, 2024
1 parent 674ca89 commit 04c5719
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public Collection<ExecutionEnvironment> getAllKnownEEs() {

@Override
public boolean ignoreExecutionEnvironment() {
return NoExecutionEnvironment.NAME.equals(getProfileName());
return NoExecutionEnvironment.NAME.equals(effectiveProfileName);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,20 @@ 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 + "]");
if (sink.ignoreExecutionEnvironment()) {
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);
}
} else {
sink.setProfileConfiguration(configuredProfileName, reason);
}
Expand Down

0 comments on commit 04c5719

Please sign in to comment.