Slackbot
04/26/2022, 7:09 PMJavi
04/26/2022, 7:28 PMefemoney
04/26/2022, 7:38 PMcredentials(PasswordCredentials::class)
that will pick up the required username & password lazily from gradle properties using the convention
"<repoName>Username"
"<repoName>Password"
Its wayyyyyyy more convenient than manually reading and setting the credentials. Unfortunately, we already have existing org-wide convention for providing these credentials to our builds that do not fit with this convention. Ours is sort of like
<org/team>_artifact_username
<org/team>_artifact_password
and is slightly different as can be supplied from properties/ env variables.
AFAIK you cannot change the convention for the API above so I’m wondering if its possible to augment the loaded gradle properties with runtime defined ones with value derived from our own properties/environment from a plugin.Javi
04/26/2022, 7:39 PMVampire
04/26/2022, 7:49 PMproviderFactory.gradleProperty(...)
so for example using extra properties will not work for that.efemoney
04/26/2022, 7:53 PMfun ProviderFactory.propOrEnv(key: String) =
gradleProperty(key).orElse(environmentVariable(key))
maven("our artifactory url") {
credentials {
username = providers.propOrEnv("our username key").get()
password = providers.propOrEnv("our password key").get()
}
}
at every use site across 100s of all our projects.
This API exists in Gradle and I would like to do
maven("our artifactory url") {
name = "ourRepo"
credentials(PasswordCredentials::class)
}
but it has a convention which we cannot support at the moment.
Wondering if there is a way I can supply those required gradle properties (for the example above ourRepoUsername
&`ourRepoPassword`) from a plugin so we can use the syntax above. Supplying via cmd line is not an option currently, its too intrusiveefemoney
04/26/2022, 7:53 PM