Hello , I have a multi-module project, and I've be...
# community-support
l
Hello , I have a multi-module project, and I've been keeping my
build.gradle
files DRY by using the
subprojects
block in the root project
build.gradle
. My question is related to dependency management in this setup. If I specify a dependency (e.g.,
com.example:library
) with
version1
in a specific module's
build.gradle
, but the same dependency is declared with
version2
in the
subprojects
block of the root project`build.gradle`, which version of the dependency will actually be used during the build process? I want to understand how Gradle resolves such conflicts when a dependency is declared both in a module-specific
build.gradle
and in the
subprojects
block with different versions. Thanks in advance for your help!
v
Besides that this is bad-practice, the result will be according to usual conflict resolution, so by default the higher version will be used if you do not have anything else configured. Using
subprojects { ... }
or any other means of doing cross-project configuration like e.g.
allprojects { ... }
,
project(...) { ... }
, and so on is discouraged bad practice and will work against more sophisticated Gradle optimizations and features. To DRY, better have a look at convention plugins in
buildSrc
or an included build, e.g. implemented as precompiled script plugin.
l
Thanks sir for your response.
👌 1