问题描述
我有一个多口味、多构建类型的 android 项目,我想集成 NewRelic 插件.但是我只需要为其中一位客户应用它,因此只能用于一种产品口味.
NewRelic 使用检测,如果我在那里应用插件,插件会生成其他风格的代码,这对我们来说是不允许的.
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 one product flavor.
NewRelic uses instrumentation and the plugin would generate code in other flavors if I applied the plugin there, and that is not permitted for us.
所以我的问题是:如何在 gradle 文件中使用 apply plugin: something
命令来仅应用于我的一种口味?
So my question is: How can I use the apply plugin: something
command in the gradle file to be applied to only one of my flavors?
推荐答案
使用此代码:
if (!getGradle().getStartParameter().getTaskRequests()
.toString().contains("Develop")){
apply plugin: 'com.google.gms.google-services'
}
getGradle().getStartParameter().getTaskRequests().toString()
返回类似 [DefaultTaskExecutionRequest{args=[:app:generateDevelopDebugSources],projectPath='null'}]
如注释中所述,Develop
必须以大写开头.
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.
这篇关于如何将插件仅应用于 gradle 中的一种口味?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!