diff --git a/changelog/@unreleased/pr-1879.v2.yml b/changelog/@unreleased/pr-1879.v2.yml new file mode 100644 index 000000000..fd47afa20 --- /dev/null +++ b/changelog/@unreleased/pr-1879.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: JavaDoc uses UTF-8 encoding by default + links: + - https://github.com/palantir/gradle-baseline/pull/1879 diff --git a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEncoding.java b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEncoding.java index d7806cba5..b049d2591 100644 --- a/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEncoding.java +++ b/gradle-baseline-java/src/main/groovy/com/palantir/baseline/plugins/BaselineEncoding.java @@ -19,13 +19,17 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.tasks.compile.JavaCompile; +import org.gradle.api.tasks.javadoc.Javadoc; public final class BaselineEncoding implements Plugin { @Override public void apply(Project project) { - project.getTasks().withType(JavaCompile.class).configureEach(javaCompileTask -> { - javaCompileTask.getOptions().setEncoding("UTF-8"); - }); + project.getTasks() + .withType(JavaCompile.class) + .configureEach(javaCompileTask -> javaCompileTask.getOptions().setEncoding("UTF-8")); + project.getTasks() + .withType(Javadoc.class) + .configureEach(javadocTask -> javadocTask.getOptions().setEncoding("UTF-8")); } } diff --git a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineEncodingIntegrationTest.groovy b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineEncodingIntegrationTest.groovy index 94bde79fc..0c67645ff 100644 --- a/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineEncodingIntegrationTest.groovy +++ b/gradle-baseline-java/src/test/groovy/com/palantir/baseline/BaselineEncodingIntegrationTest.groovy @@ -55,6 +55,10 @@ class BaselineEncodingIntegrationTest extends AbstractPluginTest { def javaFile = ''' package test; + + /** + * Test source file encoding with UTF-8 ☃ Javadoc. + */ public class Test { private static final String VALUE = "•"; }