Best practice to apply a BasePlugin

I have 2 code version to apply the BasePlugin in my own plugin.

  • Gradle version >= 2.3

     project.getPluginManager().apply( BasePlugin.class );
  • Gradle version < 2.3

     project.apply(ImmutableMap.of("type", BasePlugin.class));

The line for the older versions throw an:


if I run it with Gradle 2.3. Is there a syntax that work with newer and older versions?

Have you tried (for all versions):

Map<String, ?> plugin = new HashMap<>();
plugin.put("plugin", BasePlugin.class);

This is the same thing that happens when you do apply plugin: BasePlugin in a build script.

Thanks, this solve my problem.