https://kotlinlang.org logo
Title
d

deviant

10/31/2018, 3:18 PM
i've finally found how to disable IDE warnings:
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ['-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi']
    }
}
🕵️‍♂️🏼 1
d

dave08

10/31/2018, 3:20 PM
I really think it should be in the docs somewhere... I had the same problem.
3
j

Jonathan

10/31/2018, 3:24 PM
Do you know how to do it for maven project?
d

deviant

10/31/2018, 3:51 PM
nope, sorry. i hope jb guys will implement ide automatic intention for it
d

dave08

10/31/2018, 6:07 PM
I think this is a better version:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        freeCompilerArgs += [
                '-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi',
                '-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi'
        ]
    }
}
The
+=
adds more options (just in case you already have some elsewhere), and
Experimental
is for things like
Dispatchers.Unconfined
.
👍 1
r

rocketraman

11/01/2018, 3:44 PM
If these flags are enabled, it seems like the coroutines API has to be on the build classpath even if the project does not reference them. Is that right?
d

dave08

11/01/2018, 4:23 PM
Not sure. There's a KEEP on
use-experimental
though... for me I just put this where I do have it on my classpath.
r

rocketraman

11/01/2018, 4:36 PM
That would be the normal situation, but I have a custom build plugin with common config, and wanted to add these values there (but consumers of the plugin don't necessarily use coroutines).
I ran into build failures for consumers without coroutines
d

dave08

11/01/2018, 4:39 PM
I think this has to do with the new experimental flags in Kotlin so it might not be directly linked to coroutines. Maybe in #gradle or #build-tools someone might have a better idea...
r

rocketraman

11/01/2018, 4:48 PM
I think maybe #compiler
BTW, I also added
"-Xuse-experimental=kotlin.Experimental"
to your list above
d

dave08

11/01/2018, 4:50 PM
For inline classes and unsigned`s etc...?
r

rocketraman

11/01/2018, 4:50 PM
I was getting a warning with an annotation like
@UseExperimental(ObsoleteCoroutinesApi::class)
🤔 1
I think
UseExperimental
itself needs the flag
d

dave08

11/01/2018, 4:52 PM
Oh, that makes sense! Just funny that I don't think I needed it...
r

rocketraman

11/01/2018, 4:56 PM
I guess I should be using
@ObsoleteCoroutinesApi
directly
Yup, that works
p

Paul Woitaschek

11/02/2018, 1:01 PM
For me it fails the build when a module does not have it present:
e: Experimental API marker kotlinx.coroutines.ObsoleteCoroutinesApi is unresolved. Please make sure it's present in the module dependencies
e: Experimental API marker kotlinx.coroutines.ExperimentalCoroutinesApi is unresolved. Please make sure it's present in the module dependencies
> Task :rx:compileDebugKotlin FAILED
Is there a solution for this?
l

louiscad

11/02/2018, 1:01 PM
p

Paul Woitaschek

11/02/2018, 1:20 PM
Any workaround? 1.3.20 sounds like it's far away
l

louiscad

11/02/2018, 1:24 PM
Adding the compiler options or the annotations to code using it.