https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

jordond

06/18/2023, 11:20 PM
I’m converting my Android Compose library to a Multiplatform Compose library. Currently in my root
build.gradle.kts
I enable strict mode for the libraries by doing:
Copy code
configure(allprojects.filter { it.name != "demo" }) {
    tasks.withType<KotlinCompile>().configureEach {
        kotlinOptions {
            freeCompilerArgs = freeCompilerArgs + "-Xexplicit-api=strict"
        }
    }
}
This works for the code inside of
androidMain
but the stuff in
commonMain
is not affected. I’ve tried:
Copy code
configure(allprojects.filter { it.name != "demo" }) {
    tasks.withType<KotlinCompileCommon>().configureEach {
        compilerOptions {
            freeCompilerArgs = freeCompilerArgs + "-Xexplicit-api=strict"
        }
    }
}
But
freeCompilerArgs
is a
val
and cannot me changed. Any ideas on how to enable strict mode for the libraries?
a

Alexander.Likhachev

06/19/2023, 12:31 PM
freeCompilerArgs
in
compilerOptions
is of the
org.gradle.api.provider.ListProperty
type. You should modify your snippet to use
freeCompilerArgs.add("-Xexplicit-api=strict")
j

jordond

06/19/2023, 4:00 PM
Ah, I’m an idiot 😅 , thanks for your help! 👍
4 Views