Can someone tell me how I can get inline classes a...
# gradle
g
Can someone tell me how I can get inline classes added in Kotlin Gradle DSL? Cannot find a working solution. Need to add this inline warning to freeCompilerArguments
s
so what’s the version of kotlin that comes with with the kotlin-dsl plugin that comes with your version of gradle? If I remember correctly inline classes existed since kotlin 1.3, so is this what your gradle version comes with? you’re not supposed to change the version of the kotlin-dsl https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin But assuming that you’re gradle comes with included kotlin 1.3, you’d still have to enable this experimental feature (inline classes). Experimental features cause a warning (I guess a warning doesn’t stop compilation, but if it does “To remove the warning you have to opt in to the usage of experimental features by passing the argument -XXLanguage:+InlineClasses to kotlinc.” For the Kotlin project you’re building this would be done via
Copy code
compileKotlin {
    kotlinOptions.freeCompilerArgs += ["-XXLanguage:+InlineClasses"]
}
but of course you need it (possibly) for the buildscript itself. Maybe you can declare it in a
buildscript {...}
block!??
g
CcompileKotlin is a task, so just use tasks.compileKotlin
g
I just want the warnings to leave, but no matter where I place the compileKotlin options in Android Studio, I will get errors. Guess I just switch back to normal gradle, its a lot easier for me.
g
What is wrong with tasks.compileKotlin?
There is no magic
g
Dont get the tasks yet, how do i write them exactly?
Something like tthis? Still get errors
Oke, i found this, but still got the warnings :
Copy code
tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("--XXLanguage:+InlineClasses")
    }
}
g
Which version of Gradle do you use?
Yes this is also will work, just configure task without type-safe accessor, your problem that you passing wrong key, you need
-XXLanguage
, not
--XXLanguage