How can I write in gradle.kts to enable the K2 com...
# k2-early-adopters
k
How can I write in gradle.kts to enable the K2 compiler only when doing a debug build?
­čĹÇ 1
a
cc @Anton Mefodichev
a
@Kensuke Sano, I have found the following method: 1. In build.gradle.kts script define a new variable, like:
Copy code
val isDebugBuild by extra { project.findProperty("isDebugBuild")?.toString()?.toBoolean() ?: false }
2. Add a condition with selection of language version:
Copy code
kotlin {
    sourceSets.all {
        languageSettings {
            if (isDebugBuild) {
                languageVersion = "2.0"
            } else {
                languageVersion = "1.9"
            }
        }
    }
}
3. When run gradle build command: specify this variable as true:
Copy code
./gradlew build -PisDebugBuild=true
If I understood your request incompletely, can you please provide more details and conditions regarding the situation?