louiscad
02/20/2019, 12:06 PMkotlin {
sourceSets {
filter { it.name.startsWith("android") }.forEach {
it.languageSettings.apply {
useExperimentalAnnotation("kotlin.Experimental")
}
}
}
}
but I'm getting an error because the test sourceSets defined by the Android Gradle plugin (version 3.3.1) don't have the experimental annotation.
How can I solve that issue to enable this experimental annotation in my android source sets defined my Kotlin multiplatform gradle plugin?
The exact error message is the following:
Inconsistent settings for Kotlin source sets: 'androidDebugAndroidTest' depends on 'androidAndroidTest'
'androidDebugAndroidTest': set of experimental annotations in use is []
'androidAndroidTest': set of experimental annotations in use is [kotlin.Experimental]
The dependent source set must use all experimental annotations that its dependency uses.
h0tk3y
02/20/2019, 2:12 PMh0tk3y
02/20/2019, 2:12 PMafterEvaluate
, some of the Kotlin MPP model parts are also only available late in project configuration.h0tk3y
02/20/2019, 2:13 PMfilter { ... }.forEach { ... }
with matching { ... }.all { ... }
h0tk3y
02/20/2019, 2:13 PMkotlin {
sourceSets {
matching { it.name.startsWith("android") }.all {
it.languageSettings.apply {
useExperimentalAnnotation("kotlin.Experimental")
}
}
}
}
h0tk3y
02/20/2019, 2:14 PMmatching
+ all
will apply the lambda to the items that are not created yet, once they are created.louiscad
02/21/2019, 8:58 AMit.
in the lambda because the Action
lambda passed to all { ... }
is a receiver.
It now works perfectly, thanks for your help!