https://github.com/doist/kotlin-warning-baseline
https://github.com/doist/kotlin-warning-baseline
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/doist/kotlin-warning-baseline
- Owner: Doist
- License: mit
- Created: 2021-12-21T15:42:16.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-19T15:10:01.000Z (almost 3 years ago)
- Last Synced: 2025-03-28T10:21:42.917Z (over 1 year ago)
- Language: Kotlin
- Homepage:
- Size: 80.1 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Kotlin Warning Baseline Gradle Plugin
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](.github/workflows/warning-check.yml)) or running it locally to catch new deprecations after dependencies update.
Currently, plugin supports: Kotlin JVM, Kotlin Multiplatform and Android projects.
## Usage
Run:
```shell
./gradlew checkKotlinWarningBaseline
```
and 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.
```
### Notes
- Warnings are differentiated by plugin based on path to `kt` file, 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 `clean` and temporarily disables Gradle Build Cache for Kotlin compile tasks. So running `writeKotlinWarningBaseline` or `checkKotlinWarningBaseline` leads to **full build**.
## Setup
```kotlin
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](https://plugins.gradle.org/plugin/com.doist.gradle.kotlin-warning-baseline)
## Tasks
- `writeKotlinWarningBaseline` Create 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.
- `checkKotlinWarningBaseline` Check that all warnings are in warning baseline files for each source set in project/module.
- `removeKotlinWarningBaseline` Remove all warning baselines files in project/module.
## Release
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.
## Licence
Released under the [MIT License](https://opensource.org/licenses/MIT).