161 lines
5.7 KiB
Kotlin
161 lines
5.7 KiB
Kotlin
plugins {
|
|
id("com.android.application") version "8.4.2"
|
|
id("org.jetbrains.kotlin.android") version "1.9.24"
|
|
id("com.google.gms.google-services") version "4.4.4"
|
|
}
|
|
|
|
extra["author"] = "M_Viper"
|
|
extra["productName"] = "deskhub"
|
|
|
|
val releaseStoreFile = providers.environmentVariable("DESKHUB_RELEASE_STORE_FILE").orNull
|
|
val releaseStorePassword = providers.environmentVariable("DESKHUB_RELEASE_STORE_PASSWORD").orNull
|
|
val releaseKeyAlias = providers.environmentVariable("DESKHUB_RELEASE_KEY_ALIAS").orNull
|
|
val releaseKeyPassword = providers.environmentVariable("DESKHUB_RELEASE_KEY_PASSWORD").orNull
|
|
val releaseSigningConfigured = listOf(
|
|
releaseStoreFile,
|
|
releaseStorePassword,
|
|
releaseKeyAlias,
|
|
releaseKeyPassword,
|
|
).all { !it.isNullOrBlank() }
|
|
|
|
android {
|
|
namespace = "de.deskhub.staff"
|
|
compileSdk = 35
|
|
|
|
defaultConfig {
|
|
applicationId = "de.deskhub.staff"
|
|
minSdk = 26
|
|
targetSdk = 35
|
|
// WICHTIG: Bei jedem neuen Debug-Build erhöhen. Android erkennt eine APK mit
|
|
// unverändertem versionCode (+ gleicher Signatur) auf manchen Geräten nicht
|
|
// zuverlässig als Update, wodurch eine Neuinstallation still fehlschlagen kann.
|
|
versionCode = 52
|
|
versionName = "3.4.4"
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
}
|
|
|
|
buildFeatures {
|
|
compose = true
|
|
buildConfig = true
|
|
}
|
|
|
|
composeOptions {
|
|
kotlinCompilerExtensionVersion = "1.5.14"
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
|
|
signingConfigs {
|
|
if (releaseSigningConfigured) {
|
|
create("release") {
|
|
storeFile = file(requireNotNull(releaseStoreFile))
|
|
storePassword = requireNotNull(releaseStorePassword)
|
|
keyAlias = requireNotNull(releaseKeyAlias)
|
|
keyPassword = requireNotNull(releaseKeyPassword)
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = true
|
|
if (releaseSigningConfigured) {
|
|
signingConfig = signingConfigs.getByName("release")
|
|
}
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro",
|
|
)
|
|
}
|
|
}
|
|
|
|
testOptions {
|
|
unitTests.isIncludeAndroidResources = true
|
|
}
|
|
|
|
packaging {
|
|
resources.excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
val composeBom = platform("androidx.compose:compose-bom:2024.09.00")
|
|
implementation(composeBom)
|
|
androidTestImplementation(composeBom)
|
|
|
|
implementation("androidx.activity:activity-compose:1.9.2")
|
|
// Lint prüft beim Release-Build die Fragment-Version für registerForActivityResult (mindestens 1.3.0)
|
|
implementation("androidx.fragment:fragment-ktx:1.8.9")
|
|
implementation("androidx.compose.ui:ui")
|
|
implementation("androidx.compose.ui:ui-tooling-preview")
|
|
implementation("androidx.compose.material3:material3")
|
|
implementation("androidx.compose.material:material-icons-extended")
|
|
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
|
|
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3")
|
|
implementation("androidx.work:work-runtime-ktx:2.9.1")
|
|
implementation("androidx.navigation:navigation-compose:2.7.7")
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
|
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
implementation("com.google.code.gson:gson:2.11.0")
|
|
// Push-Benachrichtigungen (Firebase Cloud Messaging)
|
|
implementation("com.google.firebase:firebase-messaging:25.0.1")
|
|
|
|
testImplementation("junit:junit:4.13.2")
|
|
testImplementation("org.robolectric:robolectric:4.13")
|
|
testImplementation(composeBom)
|
|
testImplementation("androidx.compose.ui:ui-test-junit4")
|
|
testImplementation("androidx.test.ext:junit:1.2.1")
|
|
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
|
|
androidTestImplementation("androidx.test.ext:junit:1.2.1")
|
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
|
|
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
|
|
debugImplementation("androidx.compose.ui:ui-tooling")
|
|
debugImplementation("androidx.compose.ui:ui-test-manifest")
|
|
}
|
|
|
|
val verifyBranding by tasks.registering {
|
|
doLast {
|
|
val strings = layout.projectDirectory
|
|
.file("src/main/res/values/strings.xml")
|
|
.asFile
|
|
.readText()
|
|
check("<string name=\"app_name\">DeskHub</string>" in strings) {
|
|
"app_name muss exakt DeskHub lauten (Groß- und Kleinschreibung beachten)."
|
|
}
|
|
val readme = layout.projectDirectory.file("README.md").asFile.readText()
|
|
check("Ersteller: M_Viper" in readme) {
|
|
"README.md muss das Feld Ersteller: M_Viper enthalten."
|
|
}
|
|
check(project.extra["author"] == "M_Viper") {
|
|
"Gradle-Projektmetadatum author muss M_Viper sein."
|
|
}
|
|
}
|
|
}
|
|
|
|
val exportDebugApk by tasks.registering {
|
|
doLast {
|
|
val source = layout.buildDirectory.file("outputs/apk/debug/DeskHubMobile-debug.apk").get().asFile
|
|
check(source.isFile) { "Debug-APK wurde nicht erzeugt: $source" }
|
|
val target = layout.projectDirectory.file("artifacts/deskhub-employee-debug.apk").asFile
|
|
target.parentFile.mkdirs()
|
|
source.copyTo(target, overwrite = true)
|
|
}
|
|
}
|
|
|
|
tasks.configureEach {
|
|
if (name == "preBuild") {
|
|
dependsOn(verifyBranding)
|
|
}
|
|
if (name == "assembleDebug") {
|
|
finalizedBy(exportDebugApk)
|
|
}
|
|
}
|