spring-io / spring-javaformat

Apache License 2.0
795 stars 110 forks source link

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

Closed joshlong closed 5 months ago

joshlong commented 6 months ago

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'
}
wilkinsona commented 6 months ago

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

Which version of Gradle are you using, @joshlong?

joshlong commented 6 months ago

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

wilkinsona commented 6 months ago

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?

wilkinsona commented 6 months ago

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

wilkinsona commented 5 months ago

Closing due to the lack of requested feedback.