I am a little bit stumped at the moment. When I set out to reduce repetition in a few Gradle projects I figured what I want is simple, but it seems that I was wrong. I have 3 projects that live in separate git repositories and are built separately. These projects do however share a few common settings. These include:
- repository definitions for plugins (“pluginManagement”)
- repository definitions for dependencies (“dependencyResolutionManagement”)
- version catalog
All in all, their settings.gradle
files are all identical apart from the rootProject.name
. This includes stuff like corporate repositories, the version of the version catalog artifact and more.
I find myself copying the settings.gradle
file between all the projects whenever a change is made. I figured there must be a mechanism to load the same settings for all of them through a plugin or similar, but there does not seem to be a way. My question is therefore: How can independent projects that are not built together share a common settings.gradle
or ideally inherit from a common settings.gradle
?
In an ideal world i would store the settings file in some remote repository and be able to simply reference the URL in another settings file. Alternatively a plug-in seems reasonable, though it seems a plug-in can’t really be applied to the settings file. It would also require a repository definition for the plug-in, which would be repeated.
Are there any best practice approaches for this issue?