Skip to content

Commit

Permalink
Fail on warnings for all compilations
Browse files Browse the repository at this point in the history
Warnings are now treated for all compilations, also test compilations, for which two fixes of missing `@Target` attributes were added.

And, refactored warning configuration to be centralized in a single place.
  • Loading branch information
Whathecode committed Nov 9, 2023
1 parent e9c4fa8 commit 787315c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
40 changes: 20 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ configure( subprojects - devOpsModules ) {
generateTypeScriptDefinitions()
}

targets.configureEach {
compilations.configureEach {
def isTestSourceSet = it.name == 'test'

compilerOptions.configure((Action) {
// Treat compilation warning as errors for all compilation targets.
it.allWarningsAsErrors = true

// We do not mind being early adopters of Jetbrains APIs likely to change in the future.
it.optIn.add('kotlin.RequiresOptIn')
it.optIn.add('kotlin.time.ExperimentalTime')
it.optIn.add('kotlin.js.ExperimentalJsExport')
if (isTestSourceSet)
{
it.optIn.add('kotlinx.coroutines.ExperimentalCoroutinesApi')
}
} )
}
}

sourceSets {
commonMain {
dependencies {
Expand All @@ -110,29 +130,9 @@ configure( subprojects - devOpsModules ) {
implementation "org.reflections:reflections:${versions.reflections}"
}
}

all {
def isTestSourceSet = it.name.endsWith('Test')

languageSettings {
// We do not mind being early adopters of Jetbrains APIs likely to change in the future.
optIn('kotlin.RequiresOptIn')
optIn('kotlin.time.ExperimentalTime')
optIn('kotlin.js.ExperimentalJsExport')
if (isTestSourceSet)
{
optIn('kotlinx.coroutines.ExperimentalCoroutinesApi')
}
}
}
}
}

// Treat compilation warning as errors for all compilation targets.
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions { allWarningsAsErrors = true }
}

// Publish configuration.
// For signing and publishing to work, a 'publish.properties' file needs to be added to the root containing:
// The OpenPGP credentials to sign all artifacts:
Expand Down
1 change: 1 addition & 0 deletions carp.test/src/jsMain/kotlin/dk/cachet/carp/test/Nested.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package dk.cachet.carp.test


// The Mocha test runtime does not rely on a 'Nested' attribute in order to run tests of nested classes.
@Target( AnnotationTarget.CLASS )
actual annotation class Nested
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package dk.cachet.carp.test


// Nothing to do. This should only ignore tests on the JavaScript test runtime.
@Target( AnnotationTarget.CLASS, AnnotationTarget.FUNCTION )
actual annotation class JsIgnore

0 comments on commit 787315c

Please sign in to comment.