1

I am using a library which has a transitive dependency on a module lets assume "abc.xyz:abc-module:1.1.1", the problem is, however, all of the modules from that group are excluded in my build.gradle for some reason using

configurations  {
    compile.exclude group: "abc.xyz"
}

It causes that transitive dependency to be ignored as expected. Is there a way I can specify only to include abc-module while excluding the remaining one as previously?

1 Answers1

0

I think you should be able to do what you want with a component selection rule like

configurations {
    compile {
        resolutionStrategy {
            componentSelection {
                all { ComponentSelection selection ->
                    if (selection.candidate.group == 'abc.xyz' && selection.candidate.module != 'abc-module') {
                        selection.reject('Dependencies from group "abc.xyz" except of "abc-module" are not allowed.')
                    }
                }
            }
        }
    }
}
Vampire
  • 35,631
  • 4
  • 76
  • 102