In Compose Desktop projects, how can we manage secret keys without committing?
In Android projects, Gradle has the buildConfigField()
and resValue()
functions. They will generate a BuildConfig.java
during compile time, and we can use the values during runtime.
For example, in an Android project, first, we create two environment variables — RELEASE_API_KEY
and STAGING_API_KEY
(It can be either local computer, or a CI/CD environment).
Then in build.gradle file we can say:
android {
buildTypes {
release {
buildConfigField("String", "API_KEY", "\"${System.getenv('RELEASE_API_KEY')}\"")
}
staging {
buildConfigField("String", "API_KEY", "\"{System.getenv('STAGING_API_KEY')}\"")
}
}
}
..and in the Kotlin code we can use:
val apiManager = ApiManager( BuildConfig.API_KEY )
Is there a similar approach in Compose Desktop projects so that:
- I don't have to commit the secret to the source repository?
- I can easily configure secrets in a CI/CD environment?