So I upgraded to 1.0.0 and I'm getting experimenta...
# coroutines
u
So I upgraded to 1.0.0 and I'm getting experimental warnings for all sorts of coroutine APIs (
produce
,
UNDISPATCHED
, etc). According to the docs I can opt in via "the compiler argument -Xuse-experimental=kotlin.Experimental" but I can't for the life of me figure out how to specify this in my gradle files. I tried adding this to my root build.gradle, but it's not working:
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            freeCompilerArgs += [
                    '-Xuse-experimental=kotlin.Experimental'
            ]
        }
    }
Does anybody know how I can opt-in properly?
👍 1
g
Did you add it to all your modules or allprojects{} block?
u
allprojects
g
Ah, got it
Use annotation kotlinx.coroutines.ExperimentalCoroutinesApi instead in your arguments
👍 2
u
That worked! Thanks a lot!
d
How would this look for Groovy/Gradle in an Android project? Is this documented?
g
The same for Android. This snippet already on Groovy
What is exactly documented? There is universal API to mark some API as experimental and universal way to enable such API using -Xuse-experimental compiler flag
d
I think the above is in Kotlin Gradle DSL... I'm still using groovy. I mean this option (is there a list of these names?), I looked for it in the Channel's guide and on main coroutines page, shouldn't this be indicated there?
I don't suppose a typical user new to coroutines will have an easy time discovering this.
g
No, this snippet is groovy
There are no single quote and collection literals in Kotlin
👍🏼 1
I mean this option (is there a list of these names?),
Why do you need list? If you have some experimental API Idea and compiler will warn you about experimental status of it and suggest to apply experimental annotation to your function/class, this annotation is what you can pass to compiler to enable such API for whole project
d
It's not that obvious for those that didn't see that KEEP, and the IDE isn't really clear about it in the tooltip.
g
Yes, I agree, probably it's possible to improve ide tooltip text
d
I saw that list, but i didn't know how to enable these until you pointed me to the KEEP and then one has to look up the proper Gradle syntax for it.
g
Kotlin Gradle plugin DSL for flags is definitely a problem There is an issue about this