2

I'm in a need of conditionally applying the com.google.gms.google-services plugin in my project only to certain flavours.

I managed to achieve this analogically to this approach, but it works for static values only (meaning I need to hardcode the flavours that I want to add this plugin to).

I'm searching for a solution that would allow me applying the plugin only if a certain flavour contains the google-services.json file (or it is in the project's inheritance tree), so the solution is flexible and does not require keeping the list up-to-date.

I managed to scan for the existence of this file for all the build variants using the project.android.applicationVariants property, but this check is being done already once all the plugins are applied. This means that the results of this scan are not needed anymore.

Is there any way to use the project's applicationVariants property on an earlier stage, before applying the plugin?

mrpasqal
  • 1,000
  • 1
  • 6
  • 26

1 Answers1

0

After all I followed the solution that enables the plugin, but disables the task it introduces for flavours that should not have the plugin enabled. Since it can be done in the same project.android.applicationVariants block as I checked for the google-services.json file presence, it turned out to be a perfect solution for that case.

See more: https://stackoverflow.com/a/49542745/3187706

mrpasqal
  • 1,000
  • 1
  • 6
  • 26