We have an App in Kotlin ( Android Stdio) which has different constants by environment. We are using Constants.kt const val IMAGES_API = "https://localhost:3000/v1/images" and we want to use the same variable in staging/qa/prod. The App is building in Kotlin and we are using gradle (groovy scripts) to compiling and packing the different environment staging/qa/prod. My first approach has been to create this properties on the gradle.properties and load the properties on the build.gradle file like this :
def loadProperties() {
def props = new Properties()
file("gradle.properties").withInputStream { props.load(it) }
def config = props
project.ext.config = config
}
And when I run gradle I can see the new properties, but I don't know how to get this value inside the App ( in the kotlin code).
My only idea is to create a task on build.gradle to copy a Constants.kt file by environment. But, I don't think, it's a good practice. I think, there must be another way to set different variables in the App. Please, can anybody help me with this?