Is there a recommended approach to share repositor...
# community-support
m
Is there a recommended approach to share repositories declarations between a multi module project and the included build-logic project? Both for plugins and dependencies. Currently I'm duplicating them in both
settings.gradle.kts
v
Have another build that provides a settings plugin that sets up the repositories, include that build in the other two and apply the settings plugin.
t
I just copy paste it. easier than the setting plugin mechanism IMO. can be trivial config if you force yourself to use the conventional un/pw pattern
Copy code
maven {
    name = "foo"
    setUrl("<https://foo.com>")
    credentials(org.gradle.api.credentials.PasswordCredentials::class)
}
so ~/.gradle/gradle.properties would have
Copy code
fooUsername=you@company.com
fooPassworld=fooApiToken
then you can ORG_GRALDE_PROJECT_fooUsername etc in your CI jobs.
t
Having another build do it doesn't work, I think, for
pluginManagement.repositories {}
at my last job we created a script,
repositories.settings.gradle.kts
, and applied that to each settings script. It was the one case where I agreed having an ad hoc script like that made sense. We had three separate builds in our repo and the repetition was getting annoying
1
m
v
Having another build do it doesn't work, I think, for pluginManagement.repositories {}
That depends on whether you need other settings plugins. For project plugins it works. For other settings plugins indeed not as the settings plugin is too late of course.
But if you need other settings plugins, then that settings plugin that configures the repositories can simply have a dependency on those other plugins and thus it would work fine