JavadocUtf8Plugin implements Plugin<Project> { @Override public void apply(Project project) { project.getTasks().withType(Javadoc.class).configureEach(javadoc -> { StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions(); options.charSet("UTF-8"); options.docEncoding("UTF-8"); options.setEncoding("UTF-8"); }); }  @Override void apply(Project project);  }
@Test public void apply() { project.getPlugins().apply(JavaPlugin.class); project.getPlugins().apply(JavadocUtf8Plugin.class); Javadoc javadoc = (Javadoc) project.getTasks().getByName(JavaPlugin.JAVADOC_TASK_NAME); StandardJavadocDocletOptions options = (StandardJavadocDocletOptions) javadoc.getOptions(); assertThat(options.getDocEncoding()).isEqualToIgnoringCase("UTF-8"); assertThat(options.getEncoding()).isEqualToIgnoringCase("UTF-8"); assertThat(options.getCharSet()).isEqualToIgnoringCase("UTF-8"); }