is there a way to do something like this for all m...
# gradle
w
is there a way to do something like this for all modules in a multiplatform project?
Copy code
// ignore these warnings
kotlin.target.compilations.all {
    allKotlinSourceSets.forEach { sourceSet ->
        sourceSet.languageSettings.apply {
            useExperimentalAnnotation("kotlinx.coroutines.FlowPreview")
            useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
            useExperimentalAnnotation("io.ktor.util.KtorExperimentalAPI")
        }
    }
}
t
do you want to apply such setting to all mutliplatform Gradle modules in the project?
w
@tapchicoma i want to apply it to all multiplatform and jvm projects
t
try to add following in the root project `build.gradle.kts`:
Copy code
subprojects { subProj ->
    subProj.plugins.withId("org.jetbrains.kotlin.multiplatform") {
        subProj.extensions.configure(org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class) {
            targets.configureEach {
                compilations.configureEach {
                    sourceSets.configureEach {
                        with(languageSettings) {
                            useExperimentalAnnotation("kotlinx.coroutines.FlowPreview")
                            useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
                            useExperimentalAnnotation("io.ktor.util.KtorExperimentalAPI")
                        }
                    }
                }
            }
        }
    }
}
w
had to tweak it a little bit but this works!
Copy code
subprojects {
    plugins.withId("org.jetbrains.kotlin.multiplatform") {
        extensions.configure(org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class) {
            targets.configureEach {
                compilations.configureEach {
                    sourceSets.configureEach {
                        with(languageSettings) {
                            useExperimentalAnnotation("kotlinx.coroutines.FlowPreview")
                            useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
                            useExperimentalAnnotation("io.ktor.util.KtorExperimentalAPI")
                        }
                    }
                }
            }
        }
    }
}
👍 1
thank you!
m
@william, @tapchicoma I used the provided code above but it gives warnings for the modules that doesn’t include the library
Copy code
w: Opt-in requirement marker kotlinx.coroutines.ExperimentalCoroutinesApi is unresolved. Please make sure it's present in the module dependencies
This warning causes build fail if you define
allWarningsAsErrors
is there any way that we can suppress this warnings ?
t
afaik no