feat: upgrade build environment to JDK 21 and centralize CI configuration

- Create a composite GitHub Action `gradle-setup` to encapsulate code checkout, wrapper validation, JDK 21 setup, and Gradle caching logic.
- Update all GitHub workflows (`publish-core`, `codeql`, `scheduled-updates`, `release`, etc.) to utilize the new centralized `gradle-setup` action.
- Upgrade the project's primary JDK requirement from 17 to 21 across `jitpack.yml`, workflow files, and build-logic conventions.
- Refactor `KotlinAndroid.kt` and `build.gradle.kts` to target JVM 21 for the application while maintaining JVM 17 compatibility for published library modules (`api`, `model`, `proto`).
- Introduce a new `build-desktop` job in `reusable-check.yml` to verify desktop artifact assembly during CI.
- Implement dynamic `cache_read_only` detection in workflows to optimize Gradle cache usage across different branch types and merge groups.
- Update project documentation (`GEMINI.md`, `AGENTS.md`, `CONTRIBUTING.md`) to reflect the JDK 21 requirement and provide guidance on Robolectric configuration for the new version.
This commit is contained in:
James Rich 2026-03-27 09:25:33 -05:00
parent 9c9a1d7567
commit 8eb5970ca8
15 changed files with 130 additions and 167 deletions

View file

@ -25,14 +25,14 @@ plugins {
group = "org.meshtastic.buildlogic"
// Configure the build-logic plugins to target JDK 17
// Configure the build-logic plugins to target JDK 21
// This improves compatibility for developers building the project or consuming its libraries.
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_17 } }
kotlin { compilerOptions { jvmTarget = JvmTarget.JVM_21 } }
dependencies {
// This allows the use of the 'libs' type-safe accessor in the Kotlin source of the plugins

View file

@ -49,8 +49,13 @@ internal fun Project.configureKotlinAndroid(commonExtension: CommonExtension) {
defaultConfig.targetSdk = targetSdkVersion
}
compileOptions.sourceCompatibility = JavaVersion.VERSION_17
compileOptions.targetCompatibility = JavaVersion.VERSION_17
val javaVersion = if (project.name in listOf("api", "model", "proto")) {
JavaVersion.VERSION_17
} else {
JavaVersion.VERSION_21
}
compileOptions.sourceCompatibility = javaVersion
compileOptions.targetCompatibility = javaVersion
}
configureMokkery()
@ -170,9 +175,10 @@ internal fun Project.configureKotlinJvm() {
/** Configure base Kotlin options */
private inline fun <reified T : KotlinBaseExtension> Project.configureKotlin() {
extensions.configure<T> {
// Using Java 17 for better compatibility with consumers (e.g. plugins, older environments)
// while still supporting modern Kotlin features.
jvmToolchain(17)
val javaVersion = if (project.name in listOf("api", "model", "proto")) 17 else 21
// Using Java 17 for published modules for better compatibility with consumers (e.g. plugins, older environments),
// and Java 21 for the rest of the app.
jvmToolchain(javaVersion)
if (this is KotlinMultiplatformExtension) {
targets.configureEach {
@ -201,7 +207,8 @@ private inline fun <reified T : KotlinBaseExtension> Project.configureKotlin() {
tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
val isPublishedModule = project.name in listOf("api", "model", "proto")
jvmTarget.set(if (isPublishedModule) JvmTarget.JVM_17 else JvmTarget.JVM_21)
allWarningsAsErrors.set(warningsAsErrors)
freeCompilerArgs.addAll(
// Enable experimental coroutines APIs, including Flow