Skip to content

Commit 93ebfca

Browse files
committed
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.
1 parent 5125d5a commit 93ebfca

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,29 @@ allprojects {
2626
options.compilerArgs.add("-parameters")
2727
}
2828

29+
tasks.matching { it.name == 'formatAot' }.all { task ->
30+
task.enabled = false
31+
}
32+
33+
tasks.matching { it.name == 'formatAotTest' }.all { task ->
34+
task.enabled = false
35+
}
36+
2937
tasks.matching { it.name == 'checkFormatAot' }.all { task ->
3038
task.enabled = false
3139
}
40+
41+
tasks.matching { it.name == 'checkFormatAotTest' }.all { task ->
42+
task.enabled = false
43+
}
44+
45+
tasks.matching { it.name == "checkstyleAot" }.all { task ->
46+
task.enabled = false
47+
}
48+
49+
tasks.matching { it.name == "checkstyleAotTest" }.all { task ->
50+
task.enabled = false
51+
}
3252
}
3353

3454
if (hasProperty('buildScan')) {
@@ -51,4 +71,3 @@ tasks.register('runAllTests') {
5171
allTestsTasks
5272
}
5373
}
54-

servlet/spring-boot/java/aot/data/build.gradle

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ tasks.withType(Test).configureEach {
4040
outputs.upToDateWhen { false }
4141
}
4242

43-
compileJava {
44-
dependsOn("formatMain")
43+
if (plugins.hasPlugin("io.spring.javaformat")) {
44+
compileJava {
45+
dependsOn("formatMain")
46+
}
47+
tasks.checkFormatMain {
48+
dependsOn("formatMain")
49+
}
50+
compileTestJava {
51+
dependsOn("formatTest")
52+
}
53+
tasks.checkFormatTest {
54+
dependsOn("formatTest")
55+
}
4556
}
46-
47-
compileTestJava {
48-
dependsOn("formatTest")
49-
}
50-

0 commit comments

Comments
 (0)