This message was deleted.
# plugin-development
s
This message was deleted.
j
what you mean with fake gradle properties
e
There’s a succinct API for setting repository credentials
credentials(PasswordCredentials::class)
that will pick up the required username & password lazily from gradle properties using the convention
Copy code
"<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
Copy code
<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.
j
you can pass properties via terminal overriding the local ones which can be fakes
v
Unfortunately you cannot as far as I know. It would be good if there were for example for the Gradle properties plugin to become gradle property provider compatible. The credentials use
providerFactory.gradleProperty(...)
so for example using extra properties will not work for that.
e
Sorry if I wasnt clear @Javi. I dont want to override. This is the API I’m going for https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/repositories/AuthenticationSupported.html#credentials-java.lang.Class- We have an internal artifactory that we use across teams teams. To supply the credentials for our internal artifactory we have had to do:
Copy code
fun 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
Copy code
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 intrusive
Yeah thats what I thought @Vampire