Brian Estrada
04/22/2024, 9:13 AMChrimaeon
04/22/2024, 9:20 AMmikehearn
04/22/2024, 9:30 AMapp.jvm.system-properties.myProp = ${<http://env.MY|env.MY>_SECRET}
. To do it with the default packaging, I guess you could write some Gradle code to read the env vars and set a JVM flag that defines a system property only when that env var is present in the build environment.Chris Athanas
04/22/2024, 7:36 PM.properties
files that are .gitignored
, and access them in the gradle build as so:
// build.gradle.kts
(:composeApp)
val props: Properties = Properties()
props.load(project.file("./../local.properties").inputStream())
identity.set(props.getProperty("SIGNING_IDENTITY")) // example use of the property value
and in the local.properties
file:
SIGNING_IDENTITY=Chris Athanas
I also like to keep a local.properties.example
file and check this in to source control, as a placeholder and reminder what the contents of the file should look like and where it should sit in the directory structure (its so annoying to figure this out without doing this):
// local.properties.example
(check this into source control)
SIGNING_IDENTITY=<YOUR_NAME_HERE>
mohamed rejeb
04/23/2024, 7:42 AMStefan Oltmann
04/23/2024, 10:31 AM// region AppApiKeys
project.afterEvaluate {
logger.lifecycle("Generate AppApiKeys.kt")
val outputDir = layout.buildDirectory.file("generated/source/commonMain/com/ashampoo/photos/").get().asFile
outputDir.mkdirs()
val file = File(outputDir.absolutePath, "AppApiKeys.kt")
val keyNames = listOf(
"SENTRY_ANDROID_DSN", "SENTRY_DESKTOP_DSN", "SENTRY_IOS_DSN", "SENTRY_MACOS_DSN"
)
file.printWriter().use { writer ->
writer.println("package com.ashampoo.photos")
writer.println()
for (keyName in keyNames) {
var keyValue = System.getenv(keyName)
if (keyValue == null)
keyValue = ""
writer.println("const val $keyName: String = \"$keyValue\"")
}
writer.flush()
}
}
// endregion
Chrimaeon
04/23/2024, 10:36 AMafterEvaluate
is bad practice and should be avoided. You should rather put that in a plugin or register a task that runs at the right time.Stefan Oltmann
04/23/2024, 11:28 AMStefan Oltmann
04/23/2024, 11:29 AMChrimaeon
04/23/2024, 11:41 AMStefan Oltmann
04/23/2024, 11:43 AMChrimaeon
04/23/2024, 11:44 AMStefan Oltmann
04/23/2024, 11:45 AMChrimaeon
04/23/2024, 11:45 AMStefan Oltmann
04/23/2024, 11:49 AMChrimaeon
04/23/2024, 11:50 AMChris Athanas
04/23/2024, 5:51 PMafterEvaluate
solution? Forgive me, Iβm a gradle user and not a gradle expert by any means.Chrimaeon
04/23/2024, 5:56 PMhfhbd
04/23/2024, 6:03 PMval storeVersion by tasks.registering(StoreVersion::class)
sourceSets.main {
kotlin.srcDir(storeVersion)
}