chore(build): Refactor Gradle build scripts to Kotlin DSL (#1944)

pull/1946/head
James Rich 2025-05-26 21:26:46 -05:00 zatwierdzone przez GitHub
rodzic 6332b3bd42
commit b7c0bc874c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
10 zmienionych plików z 140 dodań i 65 usunięć

Wyświetl plik

@ -103,7 +103,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
api-level: [26, 34]
api-level: [26, 35]
steps:
- uses: actions/checkout@v4

Wyświetl plik

@ -18,8 +18,8 @@ jobs:
- name: Get `versionCode` & `versionName`
run: |
echo "versionCode=$(grep -oP 'versionCode \K\d+' ./app/build.gradle)" >> $GITHUB_ENV
echo "versionName=$(grep -oP 'versionName \"\K[^\"]+' ./app/build.gradle)" >> $GITHUB_ENV
echo "versionCode=$(grep -oP 'VERSION_CODE = \K\d+' ./buildSrc/src/main/kotlin/Configs.kt)" >> $GITHUB_ENV
echo "versionName=$(grep -oP 'VERSION_NAME = \"\K[^\"]+' ./buildSrc/src/main/kotlin/Configs.kt)" >> $GITHUB_ENV
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
@ -48,7 +48,7 @@ jobs:
run: ./gradlew assembleFdroidRelease
- name: Enable Crashlytics
run: sed -i 's/useCrashlytics = false/useCrashlytics = true/g' ./build.gradle
run: sed -i 's/USE_CRASHLYTICS = false/USE_CRASHLYTICS = true/g' ./buildSrc/src/main/kotlin/Configs.kt
- name: Build Play Store release
run: ./gradlew bundleGoogleRelease assembleGoogleRelease

1
.gitignore vendored
Wyświetl plik

@ -15,6 +15,7 @@
.externalNativeBuild
.cxx
/app/release
/buildSrc/build
# Java KeyStore certificates
*.jks

Wyświetl plik

@ -27,13 +27,13 @@ android {
storePassword keystoreProperties['storePassword']
}
}
compileSdk 36
compileSdk Configs.COMPILE_SDK
defaultConfig {
applicationId "com.geeksville.mesh"
minSdkVersion 23
targetSdk 36
versionCode 30603 // format is Mmmss (where M is 1+the numeric major number
versionName "2.6.3"
applicationId Configs.APPLICATION_ID
minSdkVersion Configs.MIN_SDK_VERSION
targetSdk Configs.TARGET_SDK
versionCode Configs.VERSION_CODE // format is Mmmss (where M is 1+the numeric major number
versionName Configs.VERSION_NAME
testInstrumentationRunner "com.geeksville.mesh.TestRunner"
// per https://developer.android.com/studio/write/vector-asset-studio
@ -49,7 +49,7 @@ android {
}
google {
dimension = 'default'
if (useCrashlytics) {
if (Configs.USE_CRASHLYTICS) {
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
}

Wyświetl plik

@ -1,51 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
useCrashlytics = false
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath libs.agp
classpath libs.kotlin.gradle.plugin
classpath libs.kotlin.serialization
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Firebase Crashlytics
if (useCrashlytics) {
classpath libs.google.services
classpath libs.firebase.crashlytics.gradle
}
// protobuf plugin - docs here https://github.com/google/protobuf-gradle-plugin
classpath libs.protobuf.gradle.plugin
classpath libs.hilt.android.gradle.plugin
}
}
plugins {
alias (libs.plugins.kotlin.jvm) apply false
alias (libs.plugins.devtools.ksp) apply false
alias (libs.plugins.compose) apply false
}
allprojects {
repositories {
google()
mavenCentral()
// jcenter()
maven { url 'https://jitpack.io' }
//maven { url "https://plugins.gradle.org/m2/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

59
build.gradle.kts 100644
Wyświetl plik

@ -0,0 +1,59 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath(libs.agp)
classpath(libs.kotlin.gradle.plugin)
classpath(libs.kotlin.serialization)
// Google Play Services and Firebase Crashlytics
// If you want to use Firebase Crashlytics,
// set Configs.USE_CRASHLYTICS to true in:
// buildSrc/src/main/kotlin/Configs.kt
// Disabled by default for fdroid builds
if (Configs.USE_CRASHLYTICS) {
classpath(libs.google.services)
classpath(libs.firebase.crashlytics.gradle)
}
classpath(libs.protobuf.gradle.plugin)
classpath(libs.hilt.android.gradle.plugin)
}
}
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.devtools.ksp) apply false
alias(libs.plugins.compose) apply false
}
allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
tasks.register<Delete>("clean") {
delete(layout.buildDirectory)
}

Wyświetl plik

@ -0,0 +1,24 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}

Wyświetl plik

@ -0,0 +1,26 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
object Configs {
const val APPLICATION_ID = "com.geeksville.mesh"
const val MIN_SDK_VERSION = 23
const val TARGET_SDK = 36
const val COMPILE_SDK = 36
const val VERSION_CODE = 30603 // format is Mmmss (where M is 1+the numeric major number
const val VERSION_NAME = "2.6.3"
const val USE_CRASHLYTICS = true // Set to false if you don't want to use Firebase Crashlytics
}

Wyświetl plik

@ -1,3 +0,0 @@
include ':app'
rootProject.name='Meshtastic Android'
include ':network'

Wyświetl plik

@ -0,0 +1,19 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
include(":app", ":network")
rootProject.name = "Meshtastic Android"