Exclude transitive dependency of Gradle plugin

Cristina :

Excluding a transitive dependency in Gradle is pretty straightforward:

compile('com.example.m:m:1.0') {
     exclude group: 'org.unwanted', module: 'x'
  }

How would we go around he situation in which we use a plugin:

apply: "somePlugin"

And when getting the dependencies we realize that the plugin is bringing some transitive dependencies of its own?

Louis Jacomet :

You can manipulate the classpath of the buildscript itself through:

buildscript {
    configurations {
        classpath {
            exclude group: 'org', module: 'foo' // For a global exclude
        }
    }
    dependencies {
        classpath('org:bar:1.0') {
            exclude group: 'org', module: 'baz' // For excluding baz from bar but not if brought elsewhere
        }
    }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=132398&siteId=1