Arunkumar helped me get that working, but I can't ...
# gradle
s
Arunkumar helped me get that working, but I can't seem to access the
kotlin
extension, and instead I have. to define it. It's ugly, but works. Anyone know of a solution?
Copy code
plugins.withType(KotlinMultiplatformPlugin::class) {
        afterEvaluate {
            val kotlin = (this as ExtensionAware).extensions.getByName("kotlin") as org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
            kotlin.sourceSets.map {
                it.apply {
                    languageSettings.apply {
                        useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
                        useExperimentalAnnotation("kotlinx.coroutines.FlowPreview")
                        useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
                    }
                }
            }
        }
    }
s
Do not use the
kotlin.sourceSets.map
, since this will iterate over the current content of the source sets. Instead, you can probably drop the
afterEvaluate
in favour of
kotlin.sourceSets.all
or
kotlin.sourceSets.configureEach
Both functions
all
and
configureEach
will apply your configuration block also to all the subsequently added sourceSets. The difference between those function is: •
all
will configure the source sets immediately (not lazy) •
configureEach
will configure the source sets when they are required (lazy)
You might also want to replace
plugins.withType(..) { }
with
plugins.withType(...).configureEach { }
to be "even more lazy"
s
Thank you for all the advice. I've followed all of it.