spring-io/spring-javaformat

document hw to fix the Gradle task inter-dependency issues you'll get if you use Gradle.

joshlong opened this issue · 5 comments

Im applying this to a codebase with Java 21 and Spring Boot 3.2.3 and it complains about missing dependency ordering if you just add the stanza suggested in the README.md.

But, if you add this to the end of the build.gradlew, it fixes things. Maybe there's a better way. I don't know.. But it took me some puzzling to figure this out.

tasks.named('compileJava') {
    it.dependsOn ':formatMain'
}

tasks.named('compileTestJava') {
    it.dependsOn ':formatTest'
}

We should fix this in the plugin rather than working around it with documentation.

Which version of Gradle are you using, @joshlong?

It's compatible with Java 21. But I'm afk at the moment. But it's among the newer ones that finally support Java 21

I can't reproduce this with Gradle 8.6:

$ ./gradlew format --console=plain --rerun-tasks
> Task :formatMain
> Task :formatTest
> Task :format

BUILD SUCCESSFUL in 664ms
2 actionable tasks: 2 executed

Can you share a minimal reproducer?

I wonder if you ran format and some other tasks at the same time, perhaps ./gradlew format build or something like that?

Closing due to the lack of requested feedback.