IDEA-369696 Fix update DaemonJvmCriteria with invalid or undefined ProjectSDK #3001
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The
Modify Daemon JVMoption end up invoking theupdateDaemonJvmtask to updategradle-daemon-jvm.propertiesfile since with8.13that file also contain download URLs for the toolchains being resolved based on the applied project resolver toolchain plugins, meaning that cannot be modified directly by the IDE and must be delegated to Gradle. To archive running a Gradle task bypassing a potential JVM criteria not matching with any locally installed toolchain theProject SDKis used instead. However, in your case theproject-jdk-nameunder.idea/misc.xmlisn't defined or points to invalidjdk.tableentry.For sure the
Project SDKmight be updated after a successful sync to point to the Daemon usedjava.hometo run the sync (this was already raised on IDEA-367680 after discussing #2947 draft PR). However, there's no guarantee that users don't manually modified it or end up in this case given not having previously synced project (i.e. import project). For this reason we should consider fallback tobundled JBRin those cases usingSystemProperties.getJavaHome(). All of that is possible given that toolchain version used byupdateDaemonJvmis less important given that will be used just to evaluate project Gradle settings but not actually compile anything.