https://kotlinlang.org logo
#announcements
Title
# announcements
e

efemoney

06/11/2019, 1:42 PM
The
use-experimental
compiler argument either does not work as advertised (has a bug) or is not configured properly. Whats the correct way to configure the
use-experimental
compiler argument with gradle (kotlin dsl) such that I do not get warnings for using experimental APIs in my code? Right now I have this
Copy code
subprojects {

  // ... 

  project.tasks.withType<KotlinCompile> {
    kotlinOptions {
      freeCompilerArgs = listOf(
        "-Xuse-experimental=kotlin.Experimental,kotlinx.coroutines.ExperimentalCoroutinesApi,kotlinx.serialization.ImplicitReflectionSerializer"
      )
    }
  }
}
in my root build gradle file but I still get warnings like in the attached image (both
Flow
and
fun dispatcher.invoke( ... )
are experimental APIs)
n

nfrankel

06/11/2019, 3:21 PM
#gradle?
e

efemoney

06/11/2019, 3:21 PM
Will x-post
Also switched to
Copy code
project.tasks.withType<KotlinCompile> {
    kotlinOptions {
      freeCompilerArgs = listOf(
        "-Xuse-experimental=kotlin.Experimental",
        "-Xuse-experimental=kotlinx.serialization.ImplicitReflectionSerializer",
        "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
        "-Xuse-experimental=kotlinx.coroutines.FlowPreview"
      )
    }
  }
…no dice.
i

ilya.gorbunov

06/11/2019, 3:55 PM
Have you refreshed project from Gradle after these changes?
e

efemoney

06/11/2019, 3:55 PM
Yes.
@ilya.gorbunov Which is the more correct definition, iniitial message (specify comma separated multiple fqcn) or the last one (specify multiple flags each with one fqcn)
i

ilya.gorbunov

06/11/2019, 3:58 PM
Both should be fine. Can you check which arguments are shown in the Kotlin facet of your module in the project structure?
e

efemoney

06/11/2019, 4:00 PM
Ah I forgot to add, I am using AS 3.6 canary and gradle kotlin dsl so extra information does not show up in project structure.
i

ilya.gorbunov

06/11/2019, 4:01 PM
Could it be that a specific KotlinCompile task overrides
freeCompilerArgs
with another list?
Do you get these experimental warnings in IDE only or during gradle build too?
e

efemoney

06/11/2019, 4:03 PM
I dont think so. I define the
freeCompilerArgs
in one location only; within
subprojects
block of the root build file. I have also tried wrapping in
project.afterEvaluate { ... }
with no luck
Err both iirc. Lemme run a gradle build to confirm. @ilya.gorbunov confirmed, warning is only in IDE.
i

ilya.gorbunov

06/11/2019, 4:14 PM
Then it's most likely related to importing these options into IDE, but it's hard to tell at this point what is wrong. Could you file an issue with details (and better with the build scripts to reproduce the problem) here https://kotl.in/issue?
e

efemoney

06/11/2019, 4:14 PM
Also confirmed, both syntaxes work for gradle build but IDE has warnings.
Alright, I’ll do that when I get home. Thanks @ilya.gorbunov
7 Views