|
|
|
@ -38,6 +38,9 @@ import javax.xml.xpath.XPathConstants; |
|
|
|
import javax.xml.xpath.XPathExpressionException; |
|
|
|
import javax.xml.xpath.XPathExpressionException; |
|
|
|
import javax.xml.xpath.XPathFactory; |
|
|
|
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.FileEdit; |
|
|
|
import io.spring.javaformat.formatter.FileFormatter; |
|
|
|
import io.spring.javaformat.formatter.FileFormatter; |
|
|
|
import org.gradle.api.DefaultTask; |
|
|
|
import org.gradle.api.DefaultTask; |
|
|
|
@ -98,6 +101,20 @@ import org.springframework.util.Assert; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MavenPluginPlugin implements Plugin<Project> { |
|
|
|
public class MavenPluginPlugin implements Plugin<Project> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final JavaFormatConfig FORMATTER_CONFIG = new JavaFormatConfig() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public JavaBaseline getJavaBaseline() { |
|
|
|
|
|
|
|
return JavaBaseline.V8; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public IndentationStyle getIndentationStyle() { |
|
|
|
|
|
|
|
return IndentationStyle.TABS; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void apply(Project project) { |
|
|
|
public void apply(Project project) { |
|
|
|
project.getPlugins().apply(JavaLibraryPlugin.class); |
|
|
|
project.getPlugins().apply(JavaLibraryPlugin.class); |
|
|
|
@ -297,7 +314,7 @@ public class MavenPluginPlugin implements Plugin<Project> { |
|
|
|
|
|
|
|
|
|
|
|
@TaskAction |
|
|
|
@TaskAction |
|
|
|
void syncAndFormat() { |
|
|
|
void syncAndFormat() { |
|
|
|
FileFormatter formatter = new FileFormatter(); |
|
|
|
FileFormatter formatter = new FileFormatter(FORMATTER_CONFIG); |
|
|
|
for (File output : this.generator.getOutputs().getFiles()) { |
|
|
|
for (File output : this.generator.getOutputs().getFiles()) { |
|
|
|
formatter.formatFiles(getProject().fileTree(output), StandardCharsets.UTF_8) |
|
|
|
formatter.formatFiles(getProject().fileTree(output), StandardCharsets.UTF_8) |
|
|
|
.forEach((edit) -> save(output, edit)); |
|
|
|
.forEach((edit) -> save(output, edit)); |
|
|
|
|