From 79fc77fadea867b77df162d4440fa9c57b77349d Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 2 Feb 2022 13:16:08 -0800 Subject: [PATCH] Upgrade to spring-javaformat 0.0.31 Closes gh-29633 --- .springjavaformatconfig | 1 + buildSrc/gradle.properties | 2 +- .../build/mavenplugin/MavenPluginPlugin.java | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .springjavaformatconfig diff --git a/.springjavaformatconfig b/.springjavaformatconfig new file mode 100644 index 0000000000..6d408bb836 --- /dev/null +++ b/.springjavaformatconfig @@ -0,0 +1 @@ +java-baseline=8 diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 3bb065791d..6a758322d2 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -1 +1 @@ -javaFormatVersion=0.0.29 +javaFormatVersion=0.0.31 diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java index 18cb7be8be..d5bf4099b8 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java @@ -38,6 +38,9 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; +import io.spring.javaformat.config.IndentationStyle; +import io.spring.javaformat.config.JavaBaseline; +import io.spring.javaformat.config.JavaFormatConfig; import io.spring.javaformat.formatter.FileEdit; import io.spring.javaformat.formatter.FileFormatter; import org.gradle.api.DefaultTask; @@ -98,6 +101,20 @@ import org.springframework.util.Assert; */ public class MavenPluginPlugin implements Plugin { + private static final JavaFormatConfig FORMATTER_CONFIG = new JavaFormatConfig() { + + @Override + public JavaBaseline getJavaBaseline() { + return JavaBaseline.V8; + } + + @Override + public IndentationStyle getIndentationStyle() { + return IndentationStyle.TABS; + } + + }; + @Override public void apply(Project project) { project.getPlugins().apply(JavaLibraryPlugin.class); @@ -297,7 +314,7 @@ public class MavenPluginPlugin implements Plugin { @TaskAction void syncAndFormat() { - FileFormatter formatter = new FileFormatter(); + FileFormatter formatter = new FileFormatter(FORMATTER_CONFIG); for (File output : this.generator.getOutputs().getFiles()) { formatter.formatFiles(getProject().fileTree(output), StandardCharsets.UTF_8) .forEach((edit) -> save(output, edit));