Apply different plugins depending on the java version


(Tom Billiet) #1

Hi,

I want to apply a different plugin depending on which JDK version is being used. More specifically:
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
apply plugin: ‘net.ltgt.errorprone’
} else {
apply plugin: ‘net.ltgt.errorprone-javacplugin’
}

This works fine, but now I’d like to get this working in the new plugins{} structure. I can’t figure out how to use any logic there. Would that be possible?


(Schalk Cronjé) #2

That is not currently possible: See https://docs.gradle.org/4.9/userguide/plugins.html#sec:plugins_block.

Your solution is still the best.

NOTE: At this point (v4.9) you will not be able to use pluginManagement.resolutionStrategy in settings.gradle either as it only allows for changing the artifact, nit the plugin id.