Dependency resolution for classes with same package structure in Gradle

773 views Asked by At

Say I have a project ProjectA with a compile dependency on core. And core depends on deepcore. Thus, ProjectA has a transitive dependency on deepcore.

So, build script for ProjectA has this

dependencies {
    compile "com.something:core:1.0.0"
}

And build script for core has this

dependencies {
    compile "com.something:deep-core:1.0.0"
}

Now, there is a class CoreService defined in both core and deepcore with the same package structure. And I am using that class from my ProjectA, which implementation will it use? How do configure my dependency so that I am using the version from core?

1

There are 1 answers

0
Michael Hobbs On

This should do what you are looking for.

dependencies {
    compile "com.something:deep-core:1.0.0" {
      exclude group: 'com.unwanted', module: 'unwanted'
    }
}