From eb81ded56a391c70721b0268c74341df91377fcd Mon Sep 17 00:00:00 2001 From: James Rich <2199651+jamesarich@users.noreply.github.com> Date: Thu, 26 Jun 2025 00:18:59 +0000 Subject: [PATCH] Refactor: Use JVM toolchain and disable Crashlytics for F-Droid (#2252) Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com> --- app/build.gradle.kts | 20 ++++++------ mesh_service_example/build.gradle.kts | 44 +-------------------------- network/build.gradle.kts | 9 +----- settings.gradle.kts | 14 +++++++++ 4 files changed, 26 insertions(+), 61 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bbec90e60..d6d314d9a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,7 +15,6 @@ * along with this program. If not, see . */ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.io.FileInputStream import java.util.Properties @@ -124,12 +123,6 @@ android { aidl = true buildConfig = true } - // Configure the build-logic plugins to target JDK 21 - // This matches the JDK used to build the project, and is not related to what is running on device. - compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 - } lint { abortOnError = false disable.add("MissingTranslation") @@ -142,9 +135,7 @@ android { kotlin { compilerOptions { - jvmToolchain { - JvmTarget.JVM_21 - } + jvmToolchain(21) freeCompilerArgs.addAll( "-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", @@ -257,3 +248,12 @@ detekt { config.setFrom("../config/detekt/detekt.yml") baseline = file("../config/detekt/detekt-baseline.xml") } + +tasks.configureEach { + if ( + name.contains("crashlytics", ignoreCase = true) && name.contains("fdroid", ignoreCase = true) + ) { + project.logger.lifecycle("Disabling Crashlytics task for F-Droid: $name") + enabled = false + } +} diff --git a/mesh_service_example/build.gradle.kts b/mesh_service_example/build.gradle.kts index 138c8531e..d2f7ca26a 100644 --- a/mesh_service_example/build.gradle.kts +++ b/mesh_service_example/build.gradle.kts @@ -15,42 +15,6 @@ * along with this program. If not, see . */ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget - -/* - * Copyright (c) 2025 Meshtastic LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * Copyright (c) 2025 Meshtastic LLC - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) @@ -84,19 +48,13 @@ android { ) } } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 - } buildFeatures { aidl = true } } kotlin { - compilerOptions { - jvmTarget = JvmTarget.JVM_21 - } + jvmToolchain(21) } // per protobuf-gradle-plugin docs, this is recommended for android diff --git a/network/build.gradle.kts b/network/build.gradle.kts index e8090f545..7ec160a63 100644 --- a/network/build.gradle.kts +++ b/network/build.gradle.kts @@ -15,7 +15,6 @@ * along with this program. If not, see . */ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { alias(libs.plugins.android.library) @@ -36,10 +35,6 @@ android { } namespace = "com.geeksville.mesh.network" - compileOptions { - sourceCompatibility(JavaVersion.VERSION_21) - targetCompatibility(JavaVersion.VERSION_21) - } flavorDimensions += "default" productFlavors { @@ -53,9 +48,7 @@ android { } kotlin { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_21) - } + jvmToolchain(21) } dependencies { diff --git a/settings.gradle.kts b/settings.gradle.kts index 99a0dcc1c..ac202999b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,3 +17,17 @@ include(":app", ":network", ":mesh_service_example") rootProject.name = "Meshtastic Android" + +plugins { + id("org.gradle.toolchains.foojay-resolver") version "1.0.0" +} + +toolchainManagement { + jvm { + javaRepositories { + repository("foojay") { + resolverClass.set(org.gradle.toolchains.foojay.FoojayToolchainResolver::class.java) + } + } + } +}