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 0d5ceee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public void setFullSpecificationForCustomProfile(List<SystemCapability> systemCa

public boolean isIgnoredByResolver();

default boolean isResolveWithEEConstraints() {
return !isIgnoredByResolver();
}

/**
* @return all known Execution Environments accessible for the same scope
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 0d5ceee

Please sign in to comment.