This is an automated email from the ASF dual-hosted git repository.
ascheman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jdeprscan-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new f6208ce Force English locale for forked jdeprscan
f6208ce is described below
commit f6208ceeb704c77028dfc2429bc7d5da48e8cde8
Author: Gerd Aschemann <[email protected]>
AuthorDate: Fri Jul 3 16:52:45 2026 +0200
Force English locale for forked jdeprscan
jdeprscan's findings ("... uses deprecated class ...") are localized by
the JDK, but JDeprScanConsumer parses them with English-only regexes. On
a non-English default locale (e.g. German "... verwendet die veraltete
Klasse ...") nothing is recognized, so no deprecation is detected and
failOnWarning never fires -- the scan silently passes and the release8/9
ITs fail on the invoker.buildResult=failure mismatch.
Pin the forked jdeprscan JVM to en/US via -J-Duser.language so its output
is always parseable, regardless of host locale or JDK vendor.
Add a unit test for the pinned arguments and a build-non-english-locale
CI job that runs the ITs under a German default locale (JAVA_TOOL_OPTIONS)
as a regression guard -- the existing matrix only runs on English runners.
Refs #76
Co-authored-by: Matthias Bünger <[email protected]>
---
.github/workflows/maven.yaml | 31 ++++++++++++++
.../plugins/jdeprscan/AbstractJDeprScanMojo.java | 17 ++++++++
.../jdeprscan/AbstractJDeprScanMojoTest.java | 47 ++++++++++++++++++++++
3 files changed, 95 insertions(+)
diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml
index 8f38b17..ad08061 100644
--- a/.github/workflows/maven.yaml
+++ b/.github/workflows/maven.yaml
@@ -52,3 +52,34 @@ jobs:
- name: Build with Maven
run: mvn verify --errors --batch-mode --show-version -Prun-its
+
+ # Regression guard for issue #76: the GitHub runners all resolve to an
English
+ # locale, so the default matrix above never exercises the localized jdeprscan
+ # output. Run the ITs once with a non-English default locale (Zulu ships the
+ # jdeprscan_de bundle); JAVA_TOOL_OPTIONS is picked up by every forked JVM,
+ # incl. the jdeprscan tool. With the locale pinning in AbstractJDeprScanMojo
+ # this stays green; without it the release8/9 ITs fail.
+ build-non-english-locale:
+
+ strategy:
+ matrix:
+ os: [ ubuntu-latest, windows-latest ]
+ fail-fast: false
+
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v7
+
+ - name: Set up JDK
+ uses: actions/setup-java@v5
+ with:
+ distribution: 'zulu'
+ java-version: 21
+ cache: 'maven'
+
+ - name: Build with Maven (German default locale)
+ env:
+ JAVA_TOOL_OPTIONS: -Duser.language=de -Duser.country=DE
+ run: mvn verify --errors --batch-mode --show-version -Prun-its
diff --git
a/src/main/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojo.java
b/src/main/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojo.java
index 4d19fb3..eeac567 100644
---
a/src/main/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojo.java
+++
b/src/main/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojo.java
@@ -70,6 +70,8 @@ public abstract class AbstractJDeprScanMojo extends
AbstractMojo {
Commandline cmd = new Commandline();
cmd.setExecutable(jExecutable);
+ addFixedLocaleOptions(cmd);
+
addJDeprScanOptions(cmd);
executeJDeprScanCommandLine(cmd, getConsumer());
@@ -77,6 +79,21 @@ public abstract class AbstractJDeprScanMojo extends
AbstractMojo {
verify();
}
+ /**
+ * Forces the forked {@code jdeprscan} JVM to a fixed English locale.
+ * <p>
+ * The tool's findings (e.g. {@code "... uses deprecated class ..."}) are
+ * localized by the JDK, but {@link
org.apache.maven.plugins.jdeprscan.consumers.JDeprScanConsumer}
+ * parses them with English-only regular expressions. Without pinning the
+ * locale, a non-English default (e.g. German {@code "... verwendet die
+ * veraltete Klasse ..."}) is not recognized, so no deprecation is detected
+ * and {@code failOnWarning} never triggers. See issue #76.
+ */
+ static void addFixedLocaleOptions(Commandline cmd) {
+ cmd.createArg().setValue("-J-Duser.language=en");
+ cmd.createArg().setValue("-J-Duser.country=US");
+ }
+
protected CommandLineUtils.StringStreamConsumer getConsumer() {
return null;
}
diff --git
a/src/test/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojoTest.java
b/src/test/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojoTest.java
new file mode 100644
index 0000000..8bafac4
--- /dev/null
+++
b/src/test/java/org/apache/maven/plugins/jdeprscan/AbstractJDeprScanMojoTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.jdeprscan;
+
+import java.util.Arrays;
+
+import org.codehaus.plexus.util.cli.Commandline;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class AbstractJDeprScanMojoTest {
+
+ /**
+ * The forked {@code jdeprscan} JVM must be pinned to an English locale so
+ * that {@link
org.apache.maven.plugins.jdeprscan.consumers.JDeprScanConsumer}'s
+ * English-only patterns can parse the tool's (otherwise localized)
findings.
+ * See issue #76.
+ */
+ @Test
+ void forcesEnglishLocaleOnForkedJvm() {
+ Commandline cmd = new Commandline();
+ cmd.setExecutable("jdeprscan");
+
+ AbstractJDeprScanMojo.addFixedLocaleOptions(cmd);
+
+ String args = Arrays.toString(cmd.getArguments());
+ assertTrue(args.contains("-J-Duser.language=en"), "should pin language
to English, was: " + args);
+ assertTrue(args.contains("-J-Duser.country=US"), "should pin country
to US, was: " + args);
+ }
+}