3.1. Google Java Format Application
All Java source code must be formatted using Google Java Format. Manual formatting is not permitted; only automated formatting through tooling is accepted.
3.1.1. VSCode Extension Configuration
Install the google-java-format-for-vs-code extension and include the following in .vscode/settings.json.
json
{
"[java]": {
"editor.defaultFormatter": "josevseb.google-java-format-for-vs-code",
"editor.formatOnSave": true
}
}3.1.2. Maven Plugin Configuration
Use spotless-maven-plugin to automate format verification during builds.
xml
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.0</version>
<configuration>
<java>
<googleJavaFormat>
<version>1.25.2</version>
<style>GOOGLE</style>
</googleJavaFormat>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>3.1.3. CI Format Verification
Detect format violations in the CI pipeline with the following command.
bash
mvn spotless:checkThe build fails if format violations are found. To auto-fix locally, run the following.
bash
mvn spotless:apply