You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,25 @@ shortcut.
182
182
183
183

184
184
185
+
## Java 21 Support
186
+
187
+
In [1211](https://github.com/palantir/palantir-java-format/pull/1211) we shipped Java 21 support. In order to use the
188
+
Java 21 formatting capabilities, ensure that either:
189
+
190
+
- the Gradle daemon and the Intellij Project SDK are set to Java 21
191
+
- or that the gradle property `palantir.native.formatter=true`. This will run the formatter as a native image,
192
+
- independent of the Gradle daemon/Intellij project JDK version.
193
+
194
+
### Native image formatter
195
+
196
+
[This comment](https://github.com/palantir/palantir-java-format/issues/952#issuecomment-2575750610) explains why we
197
+
switched to a native image for the formatter. The startup time for the native image esp. in Intellij is >10x faster than
198
+
spinning up a new JVM process that does the formatting.
199
+
However, the throughput of running the native image for a large set of files (eg. running `./gradlew spotlessApply`) is
200
+
considerably slower (eg. 30s using the Java implementation vs 1m20s using the native image implementation). Therefore,
201
+
when running the formatter from `spotlessApply` we will default to using the Java implementation (if the Java version >= 21).
202
+
203
+
185
204
## Future works
186
205
187
206
-[ ] preserve [NON-NLS markers][] - these are comments that are used when implementing NLS internationalisation, and need to stay on the same line with the strings they come after.
Copy file name to clipboardExpand all lines: gradle-palantir-java-format/src/main/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPlugin.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ public void apply(Project rootProject) {
Copy file name to clipboardExpand all lines: gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/NativeImageFormatProviderPlugin.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ public void apply(Project rootProject) {
37
37
rootProject == rootProject.getRootProject(),
38
38
"May only apply com.palantir.java-format-provider to the root project");
39
39
40
-
if (!shouldUseNativeImage(rootProject)) {
40
+
if (!isNativeImageConfigured(rootProject)) {
41
41
log.info("Skipping native image configuration as it is not supported on this platform");
42
42
return;
43
43
}
@@ -68,7 +68,7 @@ public void apply(Project rootProject) {
Copy file name to clipboardExpand all lines: gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatPluginTest.groovy
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -93,8 +93,8 @@ class PalantirJavaFormatPluginTest extends IntegrationTestKitSpec {
93
93
'''.stripIndent()
94
94
95
95
where:
96
-
extraGradleProperties | expectedOutput
97
-
""| "Using legacy java formatter"
98
-
"palantir.native.formatter=true" | "Using the native-image to format"
96
+
extraGradleProperties | expectedOutput
97
+
"" | "Using the Java-based formatter"
98
+
"palantir.native.formatter=true"| "Using the native-image formatter"
Copy file name to clipboardExpand all lines: gradle-palantir-java-format/src/test/groovy/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.groovy
0 commit comments