Slackbot
07/20/2023, 5:52 PMFrederik Lohner
07/20/2023, 5:56 PMMiles Peele
07/20/2023, 6:02 PMMiles Peele
07/20/2023, 6:02 PMFrederik Lohner
07/20/2023, 6:06 PMFrederik Lohner
07/20/2023, 6:06 PMFrederik Lohner
07/20/2023, 6:07 PMjava {
toolchain {
languageVersion.set(javaVersion.toJavaLanguageVersion())
}
}
But it looks like you are trying to set different versions for kotlin?Frederik Lohner
07/20/2023, 6:07 PMFrederik Lohner
07/20/2023, 6:07 PMFrederik Lohner
07/20/2023, 6:08 PMMiles Peele
07/20/2023, 6:11 PMVampire
07/20/2023, 7:11 PMIs the toolchain resolver plugin thing required?Depends. If you want to do auto-provisioning, yes. If you give toolchain locations manually, or just use the detection of installed toolchains, the plugin is not necessary.
Miles Peele
07/20/2023, 7:40 PMMiles Peele
07/20/2023, 7:56 PMJavaPluginExtension
like so for each project should set the JDK for both compileJava and compileKotlin tasks:
extensions.findByType<JavaPluginExtension>()?.toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
But I'm seeing different behavior:
* What went wrong:
Execution failed for task ':home-shared:decoration:compileDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 11) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
Consider using JVM toolchain: <https://kotl.in/gradle/jvm/toolchain>
It's like the compileKotlin
tasks are picking up my local JAVA_HOME
but the compileJava
tasks aren'tMiles Peele
07/20/2023, 8:03 PMsubProjects {...
block (ugly, I know) because reasons - should I configure this on a per-module plugin level?Miles Peele
07/20/2023, 8:12 PMMiles Peele
07/20/2023, 8:21 PMVampire
07/21/2023, 9:01 AMIf I understand correctly, configuring theIf you found the extension and actually configured it, yes. You might be better off to either apply the java plugin and then get the extension, failing if it is absent, or usinglike so for each project should set the JDK for both compileJava and compileKotlin tasks:JavaPluginExtension
pluginManager.withPlugin
to react to the plugin that adds the extension being applied.
With the code you showed, you depend on the plugin being applied before that code runs which for example is bad practice if you do it in a plugin as they should be written in order-independent manner.
compileDebugJavaWithJavac
sounds like we are talking about an Android build. Android builds could again be majorly different as @Frederik Lohner mentioned above.Vampire
07/21/2023, 9:02 AMI'm currently doing this in aIt's not just ugly. It introduces project coupling which is bad for various reasons, so you should really make convention plugins instead. πblock (ugly, I know)subProjects {...