Reputation: 14550
there is a library x
. it has a lot of dependencies and dependencies of dependencies. each version of x
has different tree of dependencies
x
|- x1
| |- ...
|
|- ...
in my project some of my other dependencies include x
with some specific version. some other dependencies include dependencies of x1
, x2
, xk
different versions
what i want to do i to explicitly set version of x
and enforce all its dependencies to be in a version declared by x
i chosen
Upvotes: 1
Views: 194
Reputation: 14500
If there are no other path to the dependencies of x
, then fixing the version of x
will have that effect.
However, because Gradle does conflict resolution between all participants, if a dependency of x
, let's say y
, also happens to be a dependency of z
, which is another dependency of your project, then both version of y
will be used in conflict resolution.
One way of detecting these issues and thus not being surprised by a conflict resolving an unexpected version is to use the failOnVersionConflict
resolution strategy, as it will fail resolution if two paths bring y
but with different versions.
Gradle 5.4 and before does not have a built-in mechanism to perform what you ask.
Upvotes: 1
Reputation: 639
Have you tried looking at gradle dependency constraints?
dependencies {
implementation 'org.apache.httpcomponents:httpclient'
constraints {
implementation('org.apache.httpcomponents:httpclient:4.5.3') {
because 'previous versions have a bug impacting this application'
}
implementation('commons-codec:commons-codec:1.11') {
because 'version 1.9 pulled from httpclient has bugs affecting this application'
}
}
}
You can put the constraints in a common section and then simply declare the dependencies without versions elsewhere.
Upvotes: 0