[PR #13587] feat: replace Google Java Formatter with Spotless formatters #14726

Open
opened 2026-02-16 18:19:29 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13587

State: open
Merged: No


Summary

Replaces the Google Java Formatter implementation with generic Spotless formatters that support multiple Java formatters (Google, Eclipse, Palantir, etc.).

Changes

  • Removed: googleJavaFormat formatter entirely (PATH/JAR detection was problematic)
  • Added: spotlessMaven formatter - runs mvn spotless:apply -DspotlessFiles=$FILE
  • Added: spotlessGradle formatter - runs gradle spotlessApply -PspotlessIdeHook=$FILE
  • File-specific formatting: Only formats the saved file, not entire project
  • Simple implementation matching other formatters in the codebase
  • Users can override command in opencode.json if they prefer wrapper
  • Updated documentation

Why Spotless?

  • Generic: Works with all Spotless-supported formatters (Google, Eclipse, IntelliJ, Palantir)
  • Project-aware: Uses project's build tool configuration
  • Safer: Only formats projects explicitly configured with Spotless
  • No PATH/JAR issues: Detects plugin in build files instead

Verification

  • Tested pom.xml detection with spotless-maven-plugin
  • Tested build.gradle detection with com.diffplug.spotless
  • Documentation updated with examples

Resolves #13585

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13587 **State:** open **Merged:** No --- ## Summary Replaces the Google Java Formatter implementation with generic Spotless formatters that support multiple Java formatters (Google, Eclipse, Palantir, etc.). ## Changes - **Removed**: `googleJavaFormat` formatter entirely (PATH/JAR detection was problematic) - **Added**: `spotlessMaven` formatter - runs `mvn spotless:apply -DspotlessFiles=$FILE` - **Added**: `spotlessGradle` formatter - runs `gradle spotlessApply -PspotlessIdeHook=$FILE` - File-specific formatting: Only formats the saved file, not entire project - Simple implementation matching other formatters in the codebase - Users can override command in `opencode.json` if they prefer wrapper - Updated documentation ## Why Spotless? - **Generic**: Works with all Spotless-supported formatters (Google, Eclipse, IntelliJ, Palantir) - **Project-aware**: Uses project's build tool configuration - **Safer**: Only formats projects explicitly configured with Spotless - **No PATH/JAR issues**: Detects plugin in build files instead ## Verification - Tested pom.xml detection with `spotless-maven-plugin` - Tested build.gradle detection with `com.diffplug.spotless` - Documentation updated with examples Resolves #13585
yindo added the pull-request label 2026-02-16 18:19:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14726