This project uses Google Java Format via the Spotless Maven Plugin for consistent code formatting.
mvn spotless:checkmvn spotless:applyThe formatting check is automatically run during the compile phase, so:
mvn compilewill fail if code is not properly formatted.
- Install the "google-java-format" plugin
- Go to
File→Settings→Other Settings→google-java-format Settings - Enable "Enable google-java-format"
- Install "Google Java Format for VS Code" extension
- Download eclipse-java-google-style.xml
- Import via
Window→Preferences→Java→Code Style→Formatter→Import
The project uses a custom import order that differs from the standard Google Java Format ordering:
- Project imports:
io.cassandrareaper.* - Third-party libraries: All other external dependencies
- Java standard library:
java.* - Java extensions:
javax.* - Static imports: All static imports (at the end)
import io.cassandrareaper.AppContext;
import io.cassandrareaper.core.Cluster;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang3.StringUtils;
import java.net.URI;
import java.util.Optional;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import static com.google.common.base.Preconditions.checkArgument;This ordering is automatically applied when running mvn spotless:apply.
To automatically format code before commits, you can add this to your git pre-commit hook:
#!/bin/sh
mvn spotless:apply -q
git add .The configuration includes:
- Google Java Format style
- Custom import order (project → third-party → java → javax → static)
- Remove unused imports
- Trim trailing whitespace
- End files with newline
- 2-space indentation
- 100-character line limit