Marc Knaup
04/03/2022, 9:28 PMLanguage version 1.4 is deprecated and its support will be removed in a future version of Kotlin
Zac Sweers
04/03/2022, 10:03 PM1.8
or Java 8. You really shouldn’t need to use higher unless there are specific new Java APIs you want to use.
Kotlin version - the actual kotlin language version (i.e. runtime and syntax). Separate from the java version.
sourceCompatibility
and targetCompatibility
are only for java. You have them in your KotlinCompile block but it would work anywhere.
The java bits are only necessary if you’re writing Java code, and you should really consider using the more modern toolchain APIs instead.
For kotlin - 99.9% of the time the only thing you should be caring about is jvmTarget
, and I always just set this on the KotlinCompile
tasks directly.
There is a `kotlinCompile`/`kotlinTestCompile` DSL accessor available in pure JVM projects, but I find this limiting and often causing asymetric configuration because people don’t realize the test one is separate. For your target.compilations
, you have access to advanced config but it seems wildly overkill here. The only place I’ve ever used this is for associated compilations (which, if you don’t know what that is then you don’t need to worry about it).
Everything else you’ve put is setting default values (apiVersion
, languageVersion
, etc always use the current version by default)
Your language version warning is because Gradle forced Kotlin 1.4 on its build classpath because they use Kotlin internally and restrict its versioning in an over-abundance of caution (and at the expense of plugin developers). The warning is being emitted because you’re using 1.6, which deprecates targeting that version and Gradle has not caught up yet. It does not affect your actual project’s compilation tasks though.
All of this is pretty well-documented in the Kotlin docs: https://kotlinlang.org/docs/gradle.html. I would recommend reading them (and maybe some Gradle docs on top of it) rather than rapid-firing one-offs here.dylanmei
04/04/2022, 2:45 PMConsider using the more modern toolchain APIs insteadAgree with this đź’Ż https://docs.gradle.org/current/userguide/toolchains.html