I'm trying to get Gradle JVM toolchain working for a multi module project. I was never able to get ...
a

Alex Spence

over 3 years ago
I'm trying to get Gradle JVM toolchain working for a multi module project. I was never able to get it working without specifying custom launcher for every task.. now I'm having issues getting KSP to use a custom launcher so I'm trying the global approach again. I'm setting this in my root build.gradle.kts:
kotlin {
    jvmToolchain {
        (this as JavaToolchainSpec).apply {
            languageVersion.set(JavaLanguageVersion.of(17))
        }
    }
}

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(17))
    }
}
but I'm getting errors like this When I run gradle using Java 8
No matching variant of csdisco.athena.common:data:1.5.1 was found. The consumer was configured to find an API of a library compatible with Java 8, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
             - Variant 'apiElements' capability csdisco.athena.common:data:1.5.1 declares an API of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
                 - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
             - Variant 'runtimeElements' capability csdisco.athena.common:data:1.5.1 declares a runtime of a library, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm':
                 - Incompatible because this component declares a component compatible with Java 17 and the consumer needed a component compatible with Java 8
I've tried to specify the kotlin / java toolchain blocks above per project, in allProjects or subProjects but those result in compile errors What is the proper way to configure the toolchain for multi module projects?