Suppose you have a multi-module gradle project with nested structure. Eg: module A depends on B, B depends on C and so on. And you want to exclude module C from A.
So, here's how you can exclude a 'transitive' module prj-C from prj-B at Project A
build.gradle -- at Project A
dependencies {
implementation ( project(':prj-B')){ //note the parenthesis
exclude group: 'com.gt', module: 'prj-C'
}
//other dependencies
}
Bonus:
If you want to exclude a transitive dependency (not the module) you can do the following:
dependencies {
implementation 'com.gt:libraryA'{
exclude group: 'com.gt', name : 'libararyB'
}
//other dependencies
}