https://kotlinlang.org logo
#coroutines
Title
# coroutines
u

uhe

10/30/2018, 12:34 PM
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

gildor

10/30/2018, 12:41 PM
Did you add it to all your modules or allprojects{} block?
u

uhe

10/30/2018, 12:44 PM
allprojects
g

gildor

10/30/2018, 12:47 PM
Ah, got it
Use annotation kotlinx.coroutines.ExperimentalCoroutinesApi instead in your arguments
👍 2
u

uhe

10/30/2018, 12:49 PM
That worked! Thanks a lot!
d

dave08

10/30/2018, 1:02 PM
How would this look for Groovy/Gradle in an Android project? Is this documented?
g

gildor

10/30/2018, 1:03 PM
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

dave08

10/30/2018, 1:07 PM
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

gildor

10/30/2018, 1:08 PM
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

dave08

10/30/2018, 1:15 PM
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

gildor

10/30/2018, 1:16 PM
Yes, I agree, probably it's possible to improve ide tooltip text
d

dave08

10/30/2018, 1:20 PM
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

gildor

10/30/2018, 1:22 PM
Kotlin Gradle plugin DSL for flags is definitely a problem There is an issue about this
5 Views