is there a way to do something like this for all m...
# coroutines
w
is there a way to do something like this for all modules in a 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")
        }
    }
}
c
b
You can declare the same thing in allprojects {} block in your root project
w
i'm not sure whats i should be using in that link? doesn't seem to be very relevant I have tried in the
allProjects
block but
kotlin.target
is unrecognized
asking in #gradle too
thanks
b
kotlin.target is not recognised because you need to apply kotlin plugin in root project too
w
@Big Chungus which kotlin plugin do i need to apply in the root project? multiplatform if i'm in a multiplatform project?
b
Yes
Copy code
plugins {
 kotlin("multiplatform") version "1.4.31" apply false // apply false is optional. This will register plugin APIs, but will not actually apply it to the rootModule, still allowing you to configure subprojects in it
}
w
hmm i've tried that but i'm still getting
Unresolved reference: target
in
kotlin.target.compilations.all
message has been deleted
with kotlin 1.4.21
b
As you can see it does recognise kotlin, but not target try targets
w
targets
doesn't work. i also don't think it is recognizing kotlin properly. it goes to the package when i click it. when i click the
kotlin
in one of my android modules it goes to a gradle kotlin file
b
Might be just your ide then
Also try accessing targes from kotlin dsl builder
Rather than property
w
what is the DSL builder?
c
allProjects is no longer recommended. “Another, discouraged, way to share build logic between subproject is cross project configuration via the 
subprojects {}
 and 
allprojects {}
 DSL constructs.”
that said, the recommended way does not works so well in idea currently, so maybe allProjects is not so bad after all