Exclude specific build variants

后端 未结 9 924
一向
一向 2020-12-07 11:07

I have the two default build types: debug / release and a couple of flavors: prod / dev.

Now I want to exclude the build variant dev-release, but keep all other poss

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 11:25

    One more simpler way

    android.variantFilter { variant ->
        if (variant.name == "qaDebug" || variant.name == "devRelease") {
            setIgnore(true)
        }
    }
    

    Or if you place this code inside android {} closure, android. can be omitted

    android {
        // Please always specify the reason for such filtering
        variantFilter { variant ->
            if (variant.name == "qaDebug" || variant.name == "devRelease") {
                setIgnore(true)
            }
        }
    }
    

    Please always put a meaningful comment for things like this.

    UPD: For Kotlin Gradle DSL there is another way:

    android {
        variantFilter {
            ignore = listOf("qaDebug", "devRelease").contains(name)
        }
    }
    

提交回复
热议问题