How do I retrieve val from `gradle.properties` and...
# gradle
n
How do I retrieve val from
gradle.properties
and apply it with
buildConfigField
Below doesn’t work, I mean BASE_URL is not detected.
Copy code
buildTypes.forEach {
        it.buildConfigField("String", "BASE_URL", BASE_URL)
        it.buildConfigField("String", "BASE_PLAYER_URL", BASE_PLAYER_URL)
        it.buildConfigField("String", "ACCESS_TOKEN", ACCESS_TOKEN)
    }
gradle.properties
Copy code
BASE_URL = "url"
BASE_PLAYER_URL = "url"
ACCESS_TOKEN = "token"
2
s
Your question isn't clear.
Could you post your
gradle.properties
?
If you are trying to retrieve properties from the
gradle.properties
file in your
build.gradle.kts
you can look here. https://github.com/gradle/kotlin-dsl/tree/master/samples/project-properties
👍 1
n
@snowe thanks, updated the question
s
yes, ok, so you are doing what I thought. Kotlin doesn't dynamically add the variables like groovy. Follow the above link and see how they do it.
👍 1
n
Yeah, I checked this one but couldn’t make it. Let me give it a try once again. Thanks!
s
yours would look something like
val BASE_URL: String by project
though I don't know if it works with all caps variables.
👍 1
n
ahh silly me, as it seems, a config was an obstacle, now I’ve fixed it. Thanks for your time!
s
of course.