Exclude specific build variants

后端 未结 9 920
一向
一向 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:37

    The solutions here didn't work for me - I run into this post and added this to build.gradle in my app and it solved the issue for me

    gradle.taskGraph.whenReady { graph ->
      graph.allTasks.findAll { it.name ==~ /.*MyVariant.*/ }*.enabled = false
    }
    

    This is what it does - waits for gradle to assemble the complete list of tasks to execute and then it marks all the tasks that match the name pattern as disabled

    NOTE The match is exact - the expression above lets you match any task that has "MyVariant" somewhere in it's name and it is case sensitive

提交回复
热议问题