Using one, the latest version of the dependency across all subprojects

I have multi-project build which has a lot transitive dependencies in various version.

Can I tell Gradle to keep the same dependencies version consistent across all modules (not only within one subproject like it works now)? E.g. on submodule uses slf4j 1.7.9, the other, not related to first one 1.7.6 - then 1.7.9 should be used everywhere.

I tried to use “force” as a resolution strategy, but then I have to fix one version (or a range) while for me it is ok to use just the latest version reported by my dependencies.

Grade does not perform dependency resolution across projects, except in the case of project dependencies, where transitive dependencies are included. If you want use the same version across projects at compile time, forcing, or explicitly declaring the version you want is necessary. However, like I mentioned before. if you include the subprojects as dependencies in another project, you will get the desired behavior when building the dependent project.

For example. If ‘:A’ depends on version 1.7.6 and ‘:B’ depends on version 1.7.9, each of them built independently will use their respectively declared (or resolved) versions. However, if a third project ‘:C’ depends on both ‘:A’ and ‘:B’, then the dependency will be resolved to version 1.7.9, and that will be the runtime version used.

You may run into issues because you are effectively using different versions at compile time vs runtime but this is typically not an issue when using new versions (that aren’t major versions). For the most part the differences are transparent and if there isn’t a need to have the latest version then I see no benefit from requiring so at the subproject level. Like I said, at runtime, the latest version will be used.