This message was deleted.
# community-support
s
This message was deleted.
s
You can do
extra["FOO"] as String
in that context, and it will work, maybe give this a try? Although I do have an issue about it myself, as shown here regarding some verbosity.
n
Hey @Stylianos Gakis thanks! I actually figured it out.
providers.gradleProperty
looks up both `gradle.properties`(no matters local or global) and environment variables if value isn’t present in
gradle.properties
. However, you need to be careful about that environment variables must start with
ORG_GRADLE_PROJECT
prefix. That actually solved my problem
Copy code
maven("url") {
    credentials {
        password = proviers.gradleProperty("MY_TOKEN").get() // will look up for MY_TOKEN in gradle.properties or ORG_GRADLE_PROJECT_MY_TOKEN in env vars
    }
}
s
Aha very interesting! Only thing I imagine happening is that then I name something ORG_GRADLE_PROJECT and then later I’m like wtf, why did I do that, I undo it and then I start wondering why things break 😂 I think for my future self’s sake, I will probably avoid doing this in particular. Side note, .gradleProperty() returns a
Provider
, so I guess we have to do .getOrElse on it, which potentially makes my function even simpler since I can avoid doing .has(). So in the end it can all be just
providers.gradleProperty("KEY").getOrElse(System.getenv("KEY"))
and this way I also avoid the prefix. Sounds great tbh!
n
Yeah forgot to add
get()
function. I checked your post but still don’t understand how one can access to any
properties
file inside
settings.gradle
.
extra
won’t also help in this case. Did you find any solution or am I missing something
s
Yeah I don’t think you can access
project
in there. So in that case doing
providers.gradleProperty
as you suggested must be the solution.