Requiring toolchains unconditionally (e.g., in JavaCompile
) introduced unexpected incompatible changes
#24055
Labels
closed:duplicate
Duplicated or superseeded by another issue
Expected Behavior
On Gradle 7.+, setting a tool for a default Java task (e.g.,
javaCompiler
forJavaCompile
) to a provider would fall back to the project-wide toolchain (if available) or the running JVM otherwise if the provider has no value.Current Behavior
Doing the same on Gradle 8.0 and 8.0.1 fails because the toolchain is now required unconditionally. This is problematic because there is no proper replacement available and the behavior was not previously explicitly deprecated.
Context
I'm facing this issue when using Gradle properties to configure the toolchain for a specific task. Specifically, I'm using a provider returned by
ProviderFactory#gradleProperty(String)
to derive the tool roughly as follows:Note that this wouldn't be too much of a problem if a
setter
method onProperty
that would take a provider but fallback to the convention if the provider has no value existed. (Related to the discussion in #14768)This is also somewhat related to #23990.
Steps to Reproduce
I'm not going to provide a full MCVE this time around, because the issue is sufficiently outlined above. To reproduce the problem, create a project with the following contents in a
build.gradle.kts
file and attempt to run thecompileJava
task. (You might need to also add a dummy class to the sources to avoid the task getting skipped.) On Gradle 7.+, this would cause the task to use the project-wide toolchain. However, due to the described changes, this fails on 8.0 and 8.0.1.The text was updated successfully, but these errors were encountered: