How detailed is it possible to filter transitive dependencies in gradle? I am having a field day battling the jvm-classpath. During runtime, we encounter java.lang.ClassNotFoundException: io.opentelemetry.api.internal.InstrumentationUtil
This class is supposed to be in opentelemetry-instrumentation-api? At what version was it removed or added?
The group io.opentelemtry have a number of submodules and we have many hundreds different dependencies in our build. Therefore it is not possible to force a particular version, as this will cause a number of dependencies to break.
Is there any way of forcing versioning on transitive dependencies? Ex:
Problem: I cannot have a constraint on dependency (module b) which says use of version 2.7.0, because this will cause usage of transient dependency (module d) to break. On the other hand I cannot have a contraint on dependency (module b) which says use of version 1.37.0, because this will cause usage of transient dependency (module c) to break.
Any solutions?
This class is supposed to be in opentelemetry-instrumentation-api? At what version was it removed or added?
io.opentelemetry.api.internal.InstrumentationUtil
was first added in v1.41.0 in this commit. If you are facing runtime issues, then your dependencies are being downgraded to something lower than v1.41.0 leading to ClassNotFoundException
.
Is there any way of forcing versioning on transitive dependencies?
You can technically have multiple versions of the same dependencies on the classpath as shown in this, but ultimately when compiling the main Java code, only a single version will be present. The logic of that is explained in Version conflict resolution.
Ultimately, you will need to settle on a minimum supported version of all your dependencies or libraries you are consuming. You can align all OTEL dependencies using the opentelemetry-bom
, but again you will need to figure out the correct version that works for all.
dependencies {
implementation(enforcedPlatform("io.opentelemetry:opentelemetry-bom:1.43.0"))
}