Apply a gradle plugin (errorprone) from a custom Gradle Java plugin

I suggest that you apply the plugin by class rather than by ID. This will force you to include the error prone dependency in your plugin’s dependency list as it won’t compile until you add the dependency

Eg:

import net.ltgt.gradle.errorprone.ErrorPronePlugin.class;

public class MyPlugin implements Plugin<Project> {
   public void apply(Project project) {
       project.getPluginManager().apply(ErrorPronePlugin.class);
       // custom logic here 
   } 
}