Make Javaformat and AOT work together

Spring JavaFormat seems to process all source directories,
including those that contain AOT-generated sources.

This causes failures for checkFormat as well as checkstyle.
These are failures that we can ignore since the source code
is generated.

Additionally, there is some kind of interaction between
JavaFormat and the Spring Boot AOT support that makes Gradle
think that compileJava and a few other tasks need to depend
on formatMain and formatTest.
This commit is contained in:
Josh Cummings
2024-09-25 13:30:50 -06:00
parent 5125d5aa05
commit 93ebfca7b8
2 changed files with 33 additions and 8 deletions

View File

@@ -40,11 +40,17 @@ tasks.withType(Test).configureEach {
outputs.upToDateWhen { false }
}
compileJava {
dependsOn("formatMain")
if (plugins.hasPlugin("io.spring.javaformat")) {
compileJava {
dependsOn("formatMain")
}
tasks.checkFormatMain {
dependsOn("formatMain")
}
compileTestJava {
dependsOn("formatTest")
}
tasks.checkFormatTest {
dependsOn("formatTest")
}
}
compileTestJava {
dependsOn("formatTest")
}