Title: Keep Style.PALANTIR as a @Deprecated alias for Style.OJF by glaforge · Pull Request #200 · openjavaformat/open-java-format · GitHub
Open Graph Title: Keep Style.PALANTIR as a @Deprecated alias for Style.OJF by glaforge · Pull Request #200 · openjavaformat/open-java-format
X Title: Keep Style.PALANTIR as a @Deprecated alias for Style.OJF by glaforge · Pull Request #200 · openjavaformat/open-java-format
Description: Summary
Restores JavaFormatterOptions.Style.PALANTIR as a @Deprecated alias for Style.OJF (indentationMultiplier = 2, maxLineLength = 120) in open-java-format-spi and treats Style.PALANTIR identically to Style.OJF in ImportOrderer.
Motivation: Ecosystem & Spotless Backward Compatibility
As noted in the README ("Identical Java packages. com.palantir.javaformat.* stays, so your code and the SPI keep working. One-line migration. Change the coordinates below. Nothing else."), keeping binary and reflective compatibility in com.palantir.javaformat.java.JavaFormatterOptions.Style allows existing integrations to swap coordinates without breaking:
Spotless's built-in palantirJavaFormat() step (com.diffplug.spotless.java.PalantirJavaFormatStep):
Spotless's built-in step defaults to DEFAULT_STYLE = "PALANTIR" and invokes com.palantir.javaformat.java.JavaFormatterOptions$Style.valueOf(style) via reflection. When a Gradle or Maven project overrides the dependency of Spotless's palantirJavaFormat() step to dev.openjavaformat:open-java-format without explicitly passing .style("OJF"), Style.valueOf("PALANTIR") previously threw:
java.lang.IllegalArgumentException: No enum constant com.palantir.javaformat.java.JavaFormatterOptions.Style.PALANTIR
With @Deprecated PALANTIR(2, 120) present on Style, existing Spotless palantirJavaFormat() configurations and direct Java API/SPI callers using Style.PALANTIR work out of the box as a true one-line coordinate swap.
Direct Java API / SPI callers:
Codebases calling JavaFormatterOptions.builder().style(Style.PALANTIR).build() or ImportOrderer.reorderImports(input, Style.PALANTIR) continue to compile and format identically to Style.OJF, while receiving a standard Java deprecation warning guiding them toward Style.OJF.
(Note: CLI style flag handling from e8c0ee19 is intentionally left untouched so --palantir on the CLI continues to fail fast with exit code 2 as tested in MainTest.unknownFlagIsAnError.)
Suggested Follow-up Contribution to diffplug/spotless
In addition to keeping Style.PALANTIR as a deprecated alias here for immediate backward compatibility, a natural follow-up contribution to diffplug/spotless would give open-java-format first-class support in Spotless for both Gradle and Maven users:
spotless-lib (com.diffplug.spotless.java.OpenJavaFormatStep):
Maven coordinate: dev.openjavaformat:open-java-format (default version "21.0.1" or latest 21.x)
Default style: "OJF" (supporting "OJF", "PALANTIR", "GOOGLE", "AOSP") and formatJavadoc(boolean)
Reuses the same isolated classloader / FormatterService + JavaFormatterOptions reflective invocation mechanism as PalantirJavaFormatStep (since the com.palantir.javaformat.java.* package names are preserved).
spotless-plugin-gradle (com.diffplug.gradle.spotless.JavaExtension):
Expose openJavaFormat() and openJavaFormat(String version) DSL methods on spotless { java { ... } } with .style(String) and .formatJavadoc(boolean) configuration methods.
spotless-plugin-maven (com.diffplug.spotless.maven.java.OpenJavaFormat):
Expose