I want to make sure any transitive dependencies (ie dependency of my dependencies) are using the correct version without pulling in the dependency itself.
For instance my project depends on B (and other dependencies) which depends on C. I want C to always be v2.
I tried this code
constraints {
implementation('C') {
version {
require '2'
}
because 'I cant use previous versions'
}
}
I am specifically using constraints because that seems to be gradle's recommended way of dealing with transitive properties.
However, my dependency report looks like:
runtimeClasspath
+--- B
| \--- C:2
+--- C:2
whereas without the code above, it was just
+--- B
\--- C:1.X
Meaning the v2 of the C library also got added to my runtimeClasspath directly.
Is there any gradle code that just ensure that my transitive dependencies are set to a particular version and NOT also add the library version as a direct dependency?
Thanks