I enabled the new 1.5 experimental features as out...
# announcements
a
I enabled the new 1.5 experimental features as outlined below using the "compileKotlin" block with language/api verison as 1.5. This works except I get errors on an additional test sourceSet "Task :compileLongTestKotlin FAILED" "Class 'xx' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler. I had the same issue with my test folder so added "compileTestKotlin" block with the 1.5 options which worked. Adding the same for my additional sourceset results in "Could not find method compileLongTestKotlin()" https://blog.jetbrains.com/kotlin/2021/02/new-language-features-preview-in-kotlin-1-4-30/#sealed-interfaces
m
How do you set language version 1.5 exactly? All source sets and projects that depends on 1.5 code also need to have language version 1.5 set.
a
Just with this in build.gradle compileKotlin { kotlinOptions { languageVersion = "1.5" apiVersion = "1.5" } } And then unit tests didn't work until I added compileTestKotlin { kotlinOptions { languageVersion = "1.5" apiVersion = "1.5" } } But now I have a 3rd sourceSet (another type of test) which I can't get to work. This is all the same project/module
v
Can you share an MCVE that reproduces your problem? Then it is much easier to maybe see your problem.
i
You can use the following construction to set
kotlinOptions
for all Kotlin compilations in the project:
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinCompile::class) {
    kotlinOptions { ... }
}
a
Is that the kts syntax? I'm not using gradle kts but got it to work with a modified version of that
i
Yes. In Groovy scripts, you can use the same, just without the
::class
part.
a
You can
tasks.withType<KotlinCompile> { ... }
as well o.O, it'll evaluate configuration block for all the tasks with given type.