1

I know in a groovy based build.gradle that you can define multiple excludes as described here:

dependencies {
    def withoutStuff = { 
        exclude group: 'com.android.support', module: 'support-v4' 
        exclude group: 'com.android.support', module: 'support-v13'
        exclude group: 'com.android.support', module: 'design-v13' 
    }

    // For Material Datepicker
    compile deps.datePicker, withoutStuff
}

But now how do we do this in a kotlin based build.gradle.kts file?

Naruto Sempai
  • 6,233
  • 8
  • 35
  • 51

2 Answers2

4

Ok I figured it out after much searching and trail and error. Above the dependencies you can define:

val withoutStuff = fun ExternalModuleDependency.() {
    exclude(group = "com.android.support", module = "support-v4")
    exclude(group = "com.android.support", module = "support-v13")
    exclude(group = "com.android.support", module = "design-v13")
}

and then inside of the dependencies block you can do:

dependencies {

    implementation(deps.datePicker, withoutStuff)
    ...
}

Hope that helps someone else and looking forward to other answers.

Naruto Sempai
  • 6,233
  • 8
  • 35
  • 51
2

Or if you want to globally set an exclusions, this might works:

// android {} 

configurations {
    implementation {
        exclude(group = "androidx.core", module = "app")
        exclude(group = "androidx.core", module = "core")
        exclude(group = "androidx.appcompat", module = "app")
        exclude(group = "com.google.firebase", module = "firebase-iid")
        exclude(group = "androidx.test", module = "monitor")
    }
}

// dependencies {}

Inspired by: https://stackoverflow.com/a/52165253/3763032

mochadwi
  • 1,190
  • 9
  • 32
  • 87