Skip to content

Let a build name the version of the native image - #297

Open
abashev wants to merge 1 commit into
21.X.Xfrom
abashev/native-formatter-version-property
Open

abashev wants to merge 1 commit into
21.X.Xfrom
abashev/native-formatter-version-property

Conversation

@abashev

@abashev abashev commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Before this PR

With openjavaformat.native.formatter=true the Gradle plugin formats with open-java-format-native of its own version, as palantir-java-format's does. The version comes from the plugin jar's Implementation-Version. A build can declare another image in palantirJavaFormatNative, but only with the full coordinates, classifier and extension of each platform.

A release line that publishes no native image of its own would have nothing to resolve. That is the case of the line for Java 17 (#293): the native binary does not depend on the user's JDK, so the line formats with the image of a 21.x release of the same output.

After this PR

  • openjavaformat.native.formatter.version, a Gradle property, names the version of open-java-format-native the plugin asks for.
    • By default it is the plugin's own version, so nothing changes for a build that does not set it.
    • The platform's classifier and extension are filled in as before.
    • An image declared in palantirJavaFormatNative still wins over both.
  • A new test in NativeImageResolutionTest, with and without the configuration cache. A build that declares no image and sets the property formats with the image of that version. Without the property the same build fails to resolve open-java-format-native.

The 178 tests of the Gradle plugin pass on JDK 21.

Possible downsides?

  • One more property to document. The Gradle page of openjavaformat.dev should name it next to openjavaformat.native.formatter, in a docs PR of its own.
  • A build that sets a version far from the plugin's formats with that image's output, which is the point of the property but also lets a build mix lines by mistake.

With openjavaformat.native.formatter the Gradle plugin formats with
open-java-format-native of its own version, unless the build declares the
image in palantirJavaFormatNative. A release line that publishes no native
image of its own, as the one for Java 17 (#293), would have nothing to
resolve.

openjavaformat.native.formatter.version names the version the plugin asks
for, the plugin's own by default, so nothing changes for a build that does not
set it. NativeImageResolutionTest formats with the image of the version the
build names, in a build that declares no image; without the property the same
build fails to resolve open-java-format-native.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant