Gradle。说依赖使用另一个版本的已经包含的依赖

Gradle. Say dependency to use another version of already included dependency

示例:

implementation(group: 'org.seleniumhq.selenium', name: 'selenium-remote-driver', version: '3.13.0')
implementation(group: 'com.mypack', name: "old-library", version: '1.0')

问题是 old-library 抛出 java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException 在较新的 selenium 版本中缺失。 不幸的是我无法访问源代码。 问题 - 是否可以只说 old-library 使用旧的 selenium 版本?

好吧,那是不可能的。正如我从 Gradle Slack 聊天中得到的:

than there is no way to solve it without dependency package relocation

actually, in this case problem not even on classpath level, because if 2 dependencies have the same id Gradle have to choose one of them. If you change only dependnecy id, you will have problems on runtime, because 2 dependencies with many conflicting classes will be on the same classpath. It’s valid for Java, but which version will be choosed on classpath resolution depends on classloader and you cannot rely on this