diff --git a/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java
index 0485802d8c..948f35f0cd 100644
--- a/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java
+++ b/buildSrc/src/main/java/org/springframework/boot/build/ConventionsPlugin.java
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import io.spring.javaformat.gradle.FormatTask;
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
import org.apache.maven.artifact.repository.MavenArtifactRepository;
import org.asciidoctor.gradle.jvm.AsciidoctorJPlugin;
@@ -61,9 +62,9 @@ import org.springframework.boot.build.testing.TestFailuresPlugin;
*
{@link SpringJavaFormatPlugin Spring Java Format}, {@link CheckstylePlugin
* Checkstyle}, and {@link TestFailuresPlugin Test Failures} plugins are applied
* {@link Test} tasks are configured to use JUnit Platform and use a max heap of 1024M
- * {@link JavaCompile} tasks are configured to use UTF-8 encoding and
- * {@code -parameters}
- * {@link Javadoc} tasks are configured to use UTF-8 encoding
+ * {@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured
+ * to use UTF-8 encoding
+ * {@link JavaCompile} tasks are configured to use {@code -parameters}
* {@link Jar} tasks are configured to have the following manifest entries:
*
* - {@code Automatic-Module-Name}
@@ -142,6 +143,7 @@ public class ConventionsPlugin implements Plugin {
private void configureSpringJavaFormat(Project project) {
project.getPlugins().apply(SpringJavaFormatPlugin.class);
+ project.getTasks().withType(FormatTask.class, (formatTask) -> formatTask.setEncoding("UTF-8"));
project.getPlugins().apply(CheckstylePlugin.class);
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
checkstyle.setToolVersion("8.22");