Skip to content

Commit cb7cdee

Browse files
build: pin file.encoding so the Maven build works on Windows (#2565)
* build: pin file.encoding so the Maven build generates the parser on Windows JJTree reads the .jjt under GRAMMAR_ENCODING but writes the intermediate .jj with the JVM default charset. On a platform whose default is a legacy code page the grammar's Unicode character classes are written lossily, and JavaCC then rejects the mangled ranges: Error: Line 2331, Column 294: Right end of character range '?' has a lower ordinal value than the left end of character range '?'. The Gradle build has pinned -Dfile.encoding=UTF-8 in gradle.properties since 2021, which is why only the Maven build is affected. Give it the same pin via .mvn/jvm.config and put windows-latest back in the maven_verify matrix. * build: pin file.encoding for the forked test JVMs as well ParserKeywordsUtilsTest regenerates the .jj in-process and reads it back, so it depends on the default charset the same way the build does. Surefire forks its test JVMs and those do not inherit .mvn/jvm.config, leaving them on the platform default: ParserKeywordsUtilsTest.getAllKeywordsUsingJavaCC ... <<< ERROR! org.javacc.parser.MetaParseException Gradle needs no equivalent: its test workers take their encoding from the daemon, which gradle.properties already pins.
1 parent 6c726d8 commit cb7cdee

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ jobs:
6464
strategy:
6565
fail-fast: false
6666
matrix:
67-
# windows-latest disabled: see #<issue> — record the reason, not just the comment
68-
os: [ ubuntu-latest, macos-latest ]
67+
os: [ ubuntu-latest, windows-latest, macos-latest ]
6968
steps:
7069
- uses: actions/checkout@v5
7170
with:

.mvn/jvm.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Dfile.encoding=UTF-8

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,11 @@
426426
<goals>
427427
<goal>jjtree-javacc</goal>
428428
</goals>
429+
<!--
430+
GRAMMAR_ENCODING governs reading only: JJTree writes the intermediate
431+
.jj with the JVM default charset, which mangles the grammar's non-ASCII
432+
character classes unless file.encoding is UTF-8 (see .mvn/jvm.config).
433+
-->
429434
<configuration>
430435
<javaccCmdLineArgs>
431436
<arg>-CODE_GENERATOR:"Java"</arg>
@@ -564,11 +569,13 @@
564569
@{jacocoArgLine} is resolved late, after jacoco:prepare-agent has run.
565570
Without it the JaCoCo agent would be dropped and coverage reports empty.
566571
-->
572+
<!-- Forked test JVMs do not inherit .mvn/jvm.config, so pin the encoding here too. -->
567573
<argLine>
568574
@{jacocoArgLine}
569575
--add-opens=java.base/java.lang=ALL-UNNAMED
570576
--add-opens=java.base/java.util=ALL-UNNAMED
571577
-Xmx2G -Xms800m -Xss4m
578+
-Dfile.encoding=UTF-8
572579
</argLine>
573580
</configuration>
574581
</plugin>

0 commit comments

Comments
 (0)