How to apply plugin to only one flavor in gradle?

前端 未结 5 796
我寻月下人不归
我寻月下人不归 2020-12-01 07:27

I have a multi-flavored, multi-build-typed android project and I want to integrate the NewRelic plugin. But I have to apply it only for one of the customers, thus only for o

5条回答
  •  醉话见心
    2020-12-01 08:00

    Use this code:

    if (!getGradle().getStartParameter().getTaskRequests()
            .toString().contains("Develop")){
        apply plugin: 'com.google.gms.google-services'
    }
    

    getGradle().getStartParameter().getTaskRequests().toString() returns something like [DefaultTaskExecutionRequest{args=[:app:generateDevelopDebugSources],projectPath='null'}] so as stated in the comments Develop must start with an uppercase.

提交回复
热议问题