How can I apply kotlin compiler 2??
# compiler
c
How can I apply kotlin compiler 2??
c
Is this setup or just need to run this every build?
j
In the gradle.properties file.
c
Of course, it's gradle.properties..
I put it in build.gradle.kts(product level). But build speed is still the same..
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xallow-kotlin-package", "-P", "kotlin.experimental.tryK2=true")
    }
}
e
that's wrong.
kotlinc -P
is for compiler plugins and options
c
I am sorry, I don't understand if you say so.. Could you please how to set it in detail? I just found command line for single kt file with
kotlinc -P
Copy code
tasks
    .withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>()
    .configureEach {
        compilerOptions
            .languageVersion
            .set(
                org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2
            )
    }
Should I set like this in project level?
Hmm. kotlin 1.9 version is maximum. in that case.
d
Should I set like this in project level?
Yes, you can apply changing language version to all KotlinCompilationTasks in your project OR you can create
gradle.properties
file in root of your project and add
kotlin.experimental.tryK2=true
line to it
c
@dmitriy.novozhilov Thanks I set it. But I see any build speed improves. And should I set
Copy code
ksp.Xskip-metadata-version-check=true
ksp.Xskip-prerelease-check=true
ksp.Xallow-unstable-dependencies=true
like this in the
gradle.properties
? It doesn't cause anything but also no speed improvement.
d
Can't tell anything about KSP It's better to ask in #ksp channel
c
No, I mean the three options.
d
AFAIK those arguments can not be set via properties You should pass them in freeCompilerArgs in build scripts for kotlinCompile tasks
c
So, you mean those are not necessary for K2 right?
d
They are needed if you want to compile one of your modules with K1 against dependency which was compiled with K2 If you enabled K2 in the whole project then those can be omitted