I am stuck on a dependency conflict in a multiple project system, where multiple versions of the same dependency coexist.
I created a simple demo project at GitHub.
A has two dependencies: B and C.
B has a dependency: C.
A and B both depend on C but with different version.
A dependends on C.2
B dependends on C.1
Here is the simple dependency graph:
A
|
|___ C.2
|
|___ B
|
|__ C.1
A
build.gradle
dependencies {
compile 'org.mindfulrunner:c:2.0'
compile 'org.mindfulrunner:b:1.0-SNAPSHOT'
B
build.gradle
dependencies {
compile 'org.mindfulrunner:c:1.0'
Running testNaming() in B works where c.1 is required and c.1 is only available version of C. But running testNaming_from_b() in A is failing because c.1 is required but c.2 takes over.
Following is the error output. c.1 is an abstract class while c.2 is an interface.
class org.mindfulrunner.NamingV1 has interface org.mindfulrunner.Naming as super class java.lang.IncompatibleClassChangeError: class org.mindfulrunner.NamingV1 has interface org.mindfulrunner.Naming as super class
According to Gradle doc, when resolving dependency conflict, Gradle will select highest version. So when c.1 and c.2 both are present, c.2 will be chosen.
How can I make B use c.1 but not c.2 from within A? I played around changing build.gradle with the ideas from Customizing resolution of a dependency directly. But none of them works.
Any help is highly appreciated!