Currently format task is not available as spring-boot does:

$ gradle format

FAILURE: Build failed with an exception.

* What went wrong:
Task 'format' not found in root project 'spring' and its subprojects.

* Try:
> Run gradle tasks to get a list of available tasks.
> For more on name expansion, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:name_abbreviation in the Gradle documentation.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 3s
4 actionable tasks: 4 up-to-date

A build scan was not published as you have not authenticated with server 'ge.spring.io'.
For more information, please see https://gradle.com/help/gradle-authenticating-with-gradle-enterprise.

Formatting is not enforced, gradle checkstyleTest passed but https://github.com/spring-projects/spring-framework/commit/c809fda4edc9a76562328cb6ed1db3f481ce52dc is not formatted.

$ gradle checkstyleTest

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD SUCCESSFUL in 3s
148 actionable tasks: 1 executed, 2 from cache, 145 up-to-date

A build scan was not published as you have not authenticated with server 'ge.spring.io'.
For more information, please see https://gradle.com/help/gradle-authenticating-with-gradle-enterprise.

Comment From: snicoll

Yes, we don't use javaformat in this project and that's a team decision.

Comment From: quaff

Yes, we don't use javaformat in this project and that's a team decision.

@snicoll How to prevent committing unformatted code?

Comment From: sbrannen

How to prevent committing unformatted code?

As far as we know, the formatting used historically within the core Spring Framework cannot be automated by any current tooling support. Thus, there is no way to verify that code is properly formatted within the build.

In light of that, it's the responsibility of the maintainers to ensure code is properly formatted.