Has java plugin analog android. productFlavors?

When I use android plugin I have mechanis of productFlavors. It’s very powefull mechanism. It’s create diffreent distributions for different versions (e.g. free or prod) of one project.
Whether a java plugin has similar mechanism as productFlavors?
Thanks.

There’s a solution here which could easily be refactored into a reusable plugin.