How to emulate Android's productFlavors in a pure java gradle module?


(Zak Taccardi) #1

I need three variants (flavors):

  • fake
  • staging
  • prod

fake will provide classes like FakeUser, FakeUserDb - it’s very important that these classes are not compiled into the prod or staging variant.

prod and staging are completely identical, except that I need to compile a different String url into prod vs staging (like the Android plugin’s BuildConfig field). So, I need to create an “abstract” real flavor that both prod and staging inherit.

This can be easily done with the android gradle plugin, but how can I do it in a pure java gradle module?

cc: my stack overflow post on this http://stackoverflow.com/q/37279281/891242