Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Restores
JavaFormatterOptions.Style.PALANTIRas a@Deprecatedalias forStyle.OJF(indentationMultiplier = 2,maxLineLength = 120) inopen-java-format-spiand treatsStyle.PALANTIRidentically toStyle.OJFinImportOrderer.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 incom.palantir.javaformat.java.JavaFormatterOptions.Styleallows existing integrations to swap coordinates without breaking:palantirJavaFormat()step (com.diffplug.spotless.java.PalantirJavaFormatStep):Spotless's built-in step defaults to
DEFAULT_STYLE = "PALANTIR"and invokescom.palantir.javaformat.java.JavaFormatterOptions$Style.valueOf(style)via reflection. When a Gradle or Maven project overrides the dependency of Spotless'spalantirJavaFormat()step todev.openjavaformat:open-java-formatwithout explicitly passing.style("OJF"),Style.valueOf("PALANTIR")previously threw:@Deprecated PALANTIR(2, 120)present onStyle, existing SpotlesspalantirJavaFormat()configurations and direct Java API/SPI callers usingStyle.PALANTIRwork out of the box as a true one-line coordinate swap.Codebases calling
JavaFormatterOptions.builder().style(Style.PALANTIR).build()orImportOrderer.reorderImports(input, Style.PALANTIR)continue to compile and format identically toStyle.OJF, while receiving a standard Java deprecation warning guiding them towardStyle.OJF.(Note: CLI style flag handling from
e8c0ee19is intentionally left untouched so--palantiron the CLI continues to fail fast with exit code 2 as tested inMainTest.unknownFlagIsAnError.)Suggested Follow-up Contribution to
diffplug/spotlessIn addition to keeping
Style.PALANTIRas a deprecated alias here for immediate backward compatibility, a natural follow-up contribution todiffplug/spotlesswould giveopen-java-formatfirst-class support in Spotless for both Gradle and Maven users:spotless-lib(com.diffplug.spotless.java.OpenJavaFormatStep):dev.openjavaformat:open-java-format(default version"21.0.1"or latest21.x)"OJF"(supporting"OJF","PALANTIR","GOOGLE","AOSP") andformatJavadoc(boolean)FormatterService+JavaFormatterOptionsreflective invocation mechanism asPalantirJavaFormatStep(since thecom.palantir.javaformat.java.*package names are preserved).spotless-plugin-gradle(com.diffplug.gradle.spotless.JavaExtension):openJavaFormat()andopenJavaFormat(String version)DSL methods onspotless { java { ... } }with.style(String)and.formatJavadoc(boolean)configuration methods.spotless-plugin-maven(com.diffplug.spotless.maven.java.OpenJavaFormat):<openJavaFormat>in<configuration><java>...</java></configuration>with optional<version>,<style>, and<formatJavadoc>parameters.Verification
FormatterTest.palantirStyleAliasMatchesOjfStyleverifyingStyle.valueOf("PALANTIR"),indentationMultiplier(),maxLineLength(),Formatter.formatSource,Formatter.formatSourceAndFixImports, andImportOrderer.reorderImports../gradlew formatDiff :open-java-format-spi:check :open-java-format:check :open-java-format:test.