kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
chore(build): Refactor Gradle build scripts to Kotlin DSL (#1944)
rodzic
6332b3bd42
commit
b7c0bc874c
|
@ -103,7 +103,7 @@ jobs:
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
api-level: [26, 34]
|
api-level: [26, 35]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
|
@ -18,8 +18,8 @@ jobs:
|
||||||
|
|
||||||
- name: Get `versionCode` & `versionName`
|
- name: Get `versionCode` & `versionName`
|
||||||
run: |
|
run: |
|
||||||
echo "versionCode=$(grep -oP 'versionCode \K\d+' ./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 'versionName \"\K[^\"]+' ./app/build.gradle)" >> $GITHUB_ENV
|
echo "versionName=$(grep -oP 'VERSION_NAME = \"\K[^\"]+' ./buildSrc/src/main/kotlin/Configs.kt)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Validate Gradle wrapper
|
- name: Validate Gradle wrapper
|
||||||
uses: gradle/actions/wrapper-validation@v4
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
|
@ -48,7 +48,7 @@ jobs:
|
||||||
run: ./gradlew assembleFdroidRelease
|
run: ./gradlew assembleFdroidRelease
|
||||||
|
|
||||||
- name: Enable Crashlytics
|
- 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
|
- name: Build Play Store release
|
||||||
run: ./gradlew bundleGoogleRelease assembleGoogleRelease
|
run: ./gradlew bundleGoogleRelease assembleGoogleRelease
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
||||||
/app/release
|
/app/release
|
||||||
|
/buildSrc/build
|
||||||
|
|
||||||
# Java KeyStore certificates
|
# Java KeyStore certificates
|
||||||
*.jks
|
*.jks
|
||||||
|
|
|
@ -27,13 +27,13 @@ android {
|
||||||
storePassword keystoreProperties['storePassword']
|
storePassword keystoreProperties['storePassword']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileSdk 36
|
compileSdk Configs.COMPILE_SDK
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.geeksville.mesh"
|
applicationId Configs.APPLICATION_ID
|
||||||
minSdkVersion 23
|
minSdkVersion Configs.MIN_SDK_VERSION
|
||||||
targetSdk 36
|
targetSdk Configs.TARGET_SDK
|
||||||
versionCode 30603 // format is Mmmss (where M is 1+the numeric major number
|
versionCode Configs.VERSION_CODE // format is Mmmss (where M is 1+the numeric major number
|
||||||
versionName "2.6.3"
|
versionName Configs.VERSION_NAME
|
||||||
testInstrumentationRunner "com.geeksville.mesh.TestRunner"
|
testInstrumentationRunner "com.geeksville.mesh.TestRunner"
|
||||||
|
|
||||||
// per https://developer.android.com/studio/write/vector-asset-studio
|
// per https://developer.android.com/studio/write/vector-asset-studio
|
||||||
|
@ -49,7 +49,7 @@ android {
|
||||||
}
|
}
|
||||||
google {
|
google {
|
||||||
dimension = 'default'
|
dimension = 'default'
|
||||||
if (useCrashlytics) {
|
if (Configs.USE_CRASHLYTICS) {
|
||||||
apply plugin: 'com.google.gms.google-services'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
apply plugin: 'com.google.firebase.crashlytics'
|
apply plugin: 'com.google.firebase.crashlytics'
|
||||||
}
|
}
|
||||||
|
|
51
build.gradle
51
build.gradle
|
@ -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
|
|
||||||
}
|
|
|
@ -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)
|
||||||
|
}
|
|
@ -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()
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
include ':app'
|
|
||||||
rootProject.name='Meshtastic Android'
|
|
||||||
include ':network'
|
|
|
@ -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"
|
Ładowanie…
Reference in New Issue