Anthony
Anthony

Reputation: 227

Exclude dependency in all modules except one in Gradle

I have a dependency that I need removed from all modules of my application (10 modules), except for one.

In the top level build.gradle file, I have:

configurations.all { exclude group: 'com.nasty', module: 'nasty-dependency' }

Is there an easy way to express that for modules A thru I, I want to exclude this dependency, but in module J include it?

Thanks.

Upvotes: 0

Views: 829

Answers (1)

lance-java
lance-java

Reputation: 27984

Off the top of my head

[':A', ':B', ':C'].each {
   project(it).configurations.all { exclude group: 'com.nasty', module: 'nasty-dependency }
}

Or maybe

allprojects {
   if (path !=':X') {
      configurations.all { exclude group: 'com.nasty', module: 'nasty-dependency }
   } 
} 

Upvotes: 1

Related Questions