Skip to content

Commit

Permalink
Build improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mardous committed Aug 26, 2024
1 parent 4150c25 commit 07ffe19
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import java.util.Properties
import java.io.FileInputStream

plugins {
id("com.android.application")
Expand All @@ -12,12 +11,6 @@ plugins {
id("androidx.navigation.safeargs")
}

val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

android {
compileSdk = 34
namespace = "com.simplified.wsstatussaver"
Expand All @@ -31,28 +24,28 @@ android {
versionName = "1.4.0"
}

if (!keystoreProperties.isEmpty) {
signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
}
val signingProperties = getProperties("keystore.properties")
val releaseSigning = if (signingProperties != null) {
signingConfigs.create("release") {
keyAlias = signingProperties.property("keyAlias")
keyPassword = signingProperties.property("keyPassword")
storePassword = signingProperties.property("storePassword")
storeFile = file(signingProperties.property("storeFile"))
}
} else {
signingConfigs.getByName("debug")
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
if (signingConfigs.names.contains("release")) {
signingConfig = signingConfigs.getByName("release")
}
signingConfig = releaseSigning
}
debug {
versionNameSuffix = " DEBUG"
applicationIdSuffix = ".debug"
signingConfig = releaseSigning
}
}
buildFeatures {
Expand Down Expand Up @@ -82,6 +75,18 @@ android {
}
}

fun getProperties(fileName: String): Properties? {
val file = rootProject.file(fileName)
return if (file.exists()) {
Properties().also { properties ->
file.inputStream().use { properties.load(it) }
}
} else null
}

fun Properties.property(key: String) =
this.getProperty(key) ?: "$key missing"

dependencies {
// Google/JetPack
//https://developer.android.com/jetpack/androidx/versions
Expand Down

0 comments on commit 07ffe19

Please sign in to comment.