This plugin adds tasks to control kotlin warnings in the project with the help of baseline or without it. Typical usage of the plugin would be checking that PR doesn't introduce new warnings (for example github action) or running it locally to catch new deprecations after dependencies update.
Currently, plugin supports: Kotlin JVM, Kotlin Multiplatform and Android projects.
Run:
./gradlew checkKotlinWarningBaselineand receive error in case of new warnings:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkKotlinWarningBaseline'.
> Found 3 warnings behind baseline:
.../src/main/kotlin/com/doist/gradle/KotlinWarningBaselinePlugin.kt: (3, 30): 'TaskInGraphSpec' is deprecated.
.../src/main/kotlin/com/doist/gradle/KotlinWarningBaselinePlugin.kt: (69, 72): 'TaskInGraphSpec' is deprecated.
.../src/main/kotlin/com/doist/gradle/KotlinWarningBaselinePlugin.kt: (70, 72): 'TaskInGraphSpec' is deprecated.
- Warnings are differentiated by plugin based on path to
ktfile, warning position in code (line, symbol) and warning message. So if you update code above warning position, it will change position of the warning, and you'll have to update warning baseline. - When collecting of warnings is running, plugin makes
cleanand temporarily disables Gradle Build Cache for Kotlin compile tasks. So runningwriteKotlinWarningBaselineorcheckKotlinWarningBaselineleads to full build.
plugins {
id("com.doist.gradle.kotlin-warning-baseline") version "1.0.0"
}
// Optional configuration.
kotlinWarningBaseline {
// Option to change name of warning baseline file.
// Default: "warning-baseline.txt"
baselineFileName = "..."
// Option to disable new line at the end of the baseline files.
// Default: true
insertFinalNewline = true | false
// Option to skip some Kotlin compile tasks for collecting of warnings.
// Default: undefined.
skipIf { task -> ... }
}Also see plugin page in Gradle Plugin Portal
writeKotlinWarningBaselineCreate or update warning baseline files for each source set in project/module. If there is no warnings in project/module, files won't be created/updated.checkKotlinWarningBaselineCheck that all warnings are in warning baseline files for each source set in project/module.removeKotlinWarningBaselineRemove all warning baselines files in project/module.
To release a new version, ensure CHANGELOG.md is up-to-date, and push the corresponding tag (e.g., v1.2.3). GitHub Actions handles the rest.
Released under the MIT License.