Skip to content

Commit 2dc5197

Browse files
committed
Write the javac exports message as a text block
The same message, as a text block with String.formatted instead of a String.format over concatenated pieces with %n, so that it reads in the source the way it prints. The line-continuation backslashes keep the source within the column limit without adding line breaks to the text.
1 parent a9f92e5 commit 2dc5197

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎gradle-open-java-format/src/main/java/com/palantir/javaformat/gradle/JavaFormatExtension.java‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,19 @@ private static void checkJavacIsExportedTo(ClassLoader formatterClassLoader) {
9494
String addExports = JAVAC_PACKAGES.stream()
9595
.map(javacPackage -> "--add-exports jdk.compiler/" + javacPackage + "=ALL-UNNAMED")
9696
.collect(Collectors.joining(" "));
97-
throw new GradleException(String.format(
98-
"open-java-format cannot run inside this Gradle JVM: module jdk.compiler does not export %s to it."
99-
+ " Set one of these in gradle.properties:%n%n"
100-
+ " openjavaformat.native.formatter=true%n"
101-
+ " runs the formatter as a native binary, outside the Gradle JVM"
102-
+ " (Linux with glibc, macOS, Windows on x86-64)%n%n"
103-
+ " org.gradle.jvmargs=%s%n"
104-
+ " opens javac's packages to the Gradle JVM; if the file already sets"
105-
+ " org.gradle.jvmargs, add the flags to that line%n%n"
106-
+ "See %s",
107-
String.join(", ", notExported), addExports, DOCS));
97+
throw new GradleException("""
98+
open-java-format cannot run inside this Gradle JVM: module jdk.compiler does not export %s to it. \
99+
Set one of these in gradle.properties:
100+
101+
openjavaformat.native.formatter=true
102+
runs the formatter as a native binary, outside the Gradle JVM (Linux with glibc, macOS, \
103+
Windows on x86-64)
104+
105+
org.gradle.jvmargs=%s
106+
opens javac's packages to the Gradle JVM; if the file already sets org.gradle.jvmargs, add \
107+
the flags to that line
108+
109+
See %s\
110+
""".formatted(String.join(", ", notExported), addExports, DOCS));
108111
}
109112
}

0 commit comments

Comments
 (0)