Skip to content

Commit f36c3e3

Browse files
authored
Add docs: Required export using GoogleJavaFormat on JDK 16+ (#998)
2 parents db3ae46 + 08c5820 commit f36c3e3

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

plugin-gradle/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ spotless {
187187
googleJavaFormat('1.8').aosp().reflowLongStrings().groupArtifact('com.google.googlejavaformat:google-java-format')
188188
```
189189

190+
**⚠️ Note on using Google Java Format with Java 16+**
191+
192+
Using Java 16+ with Google Java Format 1.10.0 [requires additional flags](https://github.com/google/google-java-format/releases/tag/v1.10.0) to the running JDK.
193+
These Flags can be provided using the `gradle.properties` file (See [documentation](https://docs.gradle.org/current/userguide/build_environment.html)).
194+
195+
For example the following file under `gradle.properties` will run maven with the required flags:
196+
```
197+
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
198+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
199+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
200+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
201+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
202+
```
203+
This is a workaround to a [pending issue](https://github.com/diffplug/spotless/issues/834).
204+
190205
### eclipse jdt
191206

192207
[homepage](https://www.eclipse.org/downloads/packages/). [compatible versions](https://github.com/diffplug/spotless/tree/main/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter). See [here](../ECLIPSE_SCREENSHOTS.md) for screenshots that demonstrate how to get and install the config file mentioned below.

plugin-maven/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,17 @@ any other maven phase (i.e. compile) then it can be configured as below;
212212
</googleJavaFormat>
213213
```
214214

215+
**⚠️ Note on using Google Java Format with Java 16+**
216+
217+
Using Java 16+ with Google Java Format 1.10.0 [requires additional flags](https://github.com/google/google-java-format/releases/tag/v1.10.0) to the running JDK.
218+
These Flags can be provided using `MAVEN_OPTS` environment variable or using the `./mvn/jvm.config` file (See [documentation](https://maven.apache.org/configure.html#mvn-jvm-config-file)).
219+
220+
For example the following file under `.mvn/jvm.config` will run maven with the required flags:
221+
```
222+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
223+
```
224+
This is a workaround to a [pending issue](https://github.com/diffplug/spotless/issues/834).
225+
215226
### eclipse jdt
216227

217228
[homepage](https://www.eclipse.org/downloads/packages/). [compatible versions](https://github.com/diffplug/spotless/tree/main/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter). [code](https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/java/Eclipse.java). See [here](../ECLIPSE_SCREENSHOTS.md) for screenshots that demonstrate how to get and install the config file mentioned below.

0 commit comments

Comments
 (0)