Good afternoon Gradle friends! Is anyone able to ...
# plugin-development
j
Good afternoon Gradle friends! Is anyone able to link to me documentation of how
dependencyResolutionManagement { repositories }
works? Or can someone explain it to me if it isn't documented? I understand that it is currently incubating. As far as I've been able to tell, using it makes the project's own repositories immutable, but that's all I think I understand about it. I do my version catalog management in the
settings.gradle
file, so I'll take any chances to keep as many things related to dependency management in that file as possible.
e
dependencyResolutionManagement.repositoriesMode defaults to PREFER_PROJECT (if project defines any repositories, those are used instead of settings) but can be changed to PREFER_SETTINGS (any repositories defined in project are ignored) or FAIL_ON_PROJECT_REPOS (any repositories defined in project fail the build)
j
Ok, does this mode change if I include the settings block like I mentioned in the settings file?
v
The mode changes when you or a plugin you apply changes it. It does never change by itself
j
Ok. I ask because when I manually define repositories in the settings.gradle file, it seems like plugins are unable to add their own to a project's repositories.
v
Any plugin that does, should be fixed anyway :-)
😅 1
j
I'm working on it for my own right now haha
v
It is very bad practice to do so. Only on opt-in it is ok, or at the very least with an opt-out possibility. Otherwise for example corporate projects that have rules like only using in-house motors and so on could not be followed, and if a project uses the
FAIL...
mode, well, it would fail.
j
Well, the issue is that I need to add a maven repository that points to a local folder on disc that is created by a tool the plugin executes. So it's not that straight-forward. Opt-out for sure. I'm trying to solve this by using
Gradle#settingsEvaluated
to check the state of the repositories mode when the plugin is applied to settings.
v
Just provide an extension function on an extension on
DependencyHandler
, then your consumer has the opt-in and can easily add the repository where suitable for his build
j
Good idea, thanks
👌 1