How can I turn ``` compileKotlin { kotlinOptio...
# gradle
n
How can I turn
Copy code
compileKotlin {
    kotlinOptions {
        freeCompilerArgs += "-Xuse-experimental=org.mylibrary.ExperimentalMarker"
    }
}
into the kotlin dsl? I'm trying to disable all the coroutine experimental warnings, I found
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental"]
}
in kotlin dsl, but it has a bunch of errors in the ide, for example it says "Classifier KotlinCompile does not have a companion object..."
t
I do
Copy code
tasks {
	withType(KotlinCompile::class.java).all {
		kotlinOptions {
			jvmTarget = "1.8"
			freeCompilerArgs = listOf("-Xjsr305=strict")
		}
	}
}
but (captain obvious here) upgrading to kotlin
1.3
would allow to completely the need as coroutine are officially supported
n
Thank you! I'm on 1.3, but I'm trying to use some new coroutine stuff like channels and flow that are still marked as experimental.
So I put that in my gradle file at the top level scope, and in
listOf
I put
"-Xuse-experimental=kotlinx.coroutines.flow.Flow"
, but the IDE still hightlights flow stuff in yellow and asks me to use the annotation
s
Copy code
freeCompilerArgs = listOf(
            "-Xuse-experimental=kotlin.Experimental",
            "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
            "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes",
            "-XXLanguage:+InlineClasses"
Is what I used before, might not be the latest variety though!
Or maybe now
Copy code
"-Xuse-experimental=kotlinx.coroutines.FlowPreview"
and for the channel things
Copy code
"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi"
g
This is a bit more idiomatic Kotlin DSL syntax:
Copy code
withType<KotlinCompile> {}
👍 1
e
@nk I mention it here https://kotlinlang.slack.com/archives/C0922A726/p1560260538220700. Unfortunately I havent filed an issue yet.