https://github.com/gradleup/compat-patrouille
πΎπΎ La Compat-Patrouille helps you configure your Java/Kotlin compatibility flags.πΎπΎ
https://github.com/gradleup/compat-patrouille
android gradle java kotlin
Last synced: about 1 year ago
JSON representation
πΎπΎ La Compat-Patrouille helps you configure your Java/Kotlin compatibility flags.πΎπΎ
- Host: GitHub
- URL: https://github.com/gradleup/compat-patrouille
- Owner: GradleUp
- License: mit
- Created: 2025-04-08T12:41:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-08T21:59:02.000Z (about 1 year ago)
- Last Synced: 2025-04-15T02:47:18.872Z (about 1 year ago)
- Topics: android, gradle, java, kotlin
- Language: Kotlin
- Homepage: https://GradleUp.github.io/compat-patrouille/
- Size: 72.3 KB
- Stars: 19
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://central.sonatype.com/namespace/com.gradleup.compat.patrouille)
[](https://oss.sonatype.org/content/repositories/snapshots/com/gradleup/compat/patrouille/)
# πΎ Compat-Patrouille πΎ
The Compat-Patrouille helps you configure your Java/Kotlin compatibility flags:
```kotlin
compatPatrouille {
java(17)
kotlin("2.0.21")
}
```
### Rationale
Configuring Java/Kotlin compatibility flags is a mundane task that comes with surprising amounts of questions:
* What is the difference between `sourceCompatibility` and `targetCompatibility`?
* Should I use `release` instead?
* What does `release` even mean on Android?
* Why do I need to configure Java compatibility if I only do Kotlin?
* How do I configure `release` with Kotlin?
* Should I use `tasks.withType` or `compilerOptions {}` or something else?
* Is it "1.8" or "8" or `JavaVersion.VERSION_1_8`?
* Is it `org.jetbrains.kotlin.gradle.dsl.KotlinVersion` or `kotlin.KotlinVersion`?
* And more...
La Compat Patrouille handles all of that with just two simple functions!
### Usage
```kotlin
plugins {
id("java")
// Add your Kotlin/Android plugins here
// Add the CompatPatrouille plugin
id("com.gradleup.compat.patrouille").version("0.0.0")
}
/*
* Configure all your Java/Kotlin targets with a single code block.
* This code block works regardless of if you're using Kotlin/Android/KMP/etc...
* You can copy/pate it
*/
compatPatrouille {
// Java takes an int for simplicity
java(17)
// Kotlin takes a string so you have more control of the patch release of the stdlib.
// languageVersion/apiVersion are configured with the minor version only.
kotlin("2.0.21")
}
```
If you have convention plugins, you can also use the Compat-Patrouille without all the plugin ceremony:
```kotlin
import compat.patrouille.configureJavaCompatibility
import compat.patrouille.configureKotlinCompatibility
class ConventionPlugin: Plugin {
override fun apply(target: Project) {
target.configureJavaCompatibility(17)
target.configureKotlinCompatibility("2.0.21")
}
}
```
That's it, you can now keep on with your life.
### Note
Calling `CompatPatrouilleExtension.java()` or `CompatPatrouille.kotlin()` requires the java/kotlin/android to be applied (this plugin does not use `pluginManager.withId {}`). This is typically the case if you use the `plugins {}` block. But If you're applying your plugins programmatically, make sure to call `CompatPatrouilleExtension.java()` or `CompatPatrouille.kotlin()` only after all your plugins have been applied.
### Requirements:
* Gradle 8+
* For Kotlin: Kotlin Gradle Plugin 1.9.0+
* For Android: Android Gradle Plugin 8.2.0+