-
Notifications
You must be signed in to change notification settings - Fork 42
Enable allWarningsAsErrors compiler option for :runtime and :examples:kotlin-multiplatform projects #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
compilerOptions.freeCompilerArgs.addAll( | ||
"-opt-in=kotlin.experimental.ExperimentalNativeApi", | ||
"-opt-in=kotlin.native.runtime.NativeRuntimeApi", | ||
"-opt-in=kotlinx.cinterop.ExperimentalForeignApi", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could continue using languageSettings.optIn
DSL but move it to nativeMain
source set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this approach doesn't work. The opt-ins are not passed to the dependent source sets automatically.
This causes:
Inconsistent settings for Kotlin source sets: 'androidNativeArm32Main' depends on 'nativeMain'
'androidNativeArm32Main': set of opt-in annotations in use is []
'nativeMain': set of opt-in annotations in use is [kotlin.experimental.ExperimentalNativeApi, kotlin.native.runtime.NativeRuntimeApi, kotlinx.cinterop.ExperimentalForeignApi]
The dependent source set must use all opt-in annotations that its dependency uses.
@@ -30,6 +30,12 @@ kotlin { | |||
|
|||
applyDefaultHierarchyTemplate() | |||
|
|||
targets.configureEach { | |||
compilations.configureEach { | |||
kotlinOptions.allWarningsAsErrors = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compilerOptions
can be used instead of kotlinOptions
to avoid further changes when the latter is deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
But configuring compilerOptions
in Groovy is not as handy as in Kotlin.
It is not possible to call compilerOptions.configure {}
function because of resolution ambiguity between fun configure(configuration: T.() -> Unit)
and fun configure(configuration: Action<T>)
.
So the compilerOptions.options
needs to be configured directly.
0152cb5
to
bf8df6c
Compare
kotlin.native.runtime.NativeRuntimeApi and kotlinx.cinterop.ExperimentalForeignApi opt-in requirement markers are native-only and thus not found in other modules.
06a0df6
to
70d5d37
Compare
…e.googlejavaformat-google-java-format-1.19.1 build(deps): bump com.google.googlejavaformat:google-java-format from 1.19.0 to 1.19.1
The main reason behind enabling
allWarningsAsErrors
is to make sure deprecations/warnings in Kotlin compiler and KGP are detected in the aggregate build. So that the person who makes those changes comes and fixes usages in this library.Followup to #164