Skip to content

Commit

Permalink
Try to read signing config from local properties
Browse files Browse the repository at this point in the history
  • Loading branch information
flex3r committed Dec 22, 2024
1 parent 08251ce commit 252d387
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@file:Suppress("UnstableApiUsage")

import com.android.build.gradle.internal.PropertiesValueSource
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.StringReader
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
Expand All @@ -27,20 +30,21 @@ android {
versionName = "3.9.14"

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.schemaLocation", "${layout.projectDirectory}/schemas")
}
}

androidResources {
generateLocaleConfig = true
}

val localProperties = gradleLocalProperties(rootDir, providers)
signingConfigs {
create("release") {
storeFile = file("keystore/DankChat.jks").takeIf { it.exists() } ?: File(System.getProperty("user.home") + "/dankchat/DankChat.jks")
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
keyAlias = System.getenv("SIGNING_KEY_ALIAS")
keyPassword = System.getenv("SIGNING_KEY_PASSWORD")
storePassword = localProperties.getProperty("SIGNING_STORE_PASSWORD") ?: System.getenv("SIGNING_STORE_PASSWORD")
keyAlias = localProperties.getProperty("SIGNING_KEY_ALIAS") ?: System.getenv("SIGNING_KEY_ALIAS")
keyPassword = localProperties.getProperty("SIGNING_KEY_PASSWORD") ?: System.getenv("SIGNING_KEY_PASSWORD")
}
}

Expand Down Expand Up @@ -178,3 +182,17 @@ dependencies {
testImplementation(libs.mockk)
testImplementation(libs.kotlin.test)
}

fun gradleLocalProperties(projectRootDir : File, providers: ProviderFactory) : Properties {
val properties = Properties()
val propertiesContent =
providers.of(PropertiesValueSource::class.java) {
parameters.projectRoot.set(projectRootDir)
}.get()

StringReader(propertiesContent).use { reader ->
properties.load(reader)
}

return properties
}

0 comments on commit 252d387

Please sign in to comment.