This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new abc3e50  Accept environment variable names starting with an underscore 
or of one character
abc3e50 is described below

commit abc3e5059454f0881b3ddca1e2ed2fee6771e053
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Nov 4 15:45:54 2026 +0000

    Accept environment variable names starting with an underscore or of one 
character
    
    Fixes #797
---
 .../apache/maven/plugins/invoker/InvokerProperties.java    |  2 +-
 .../maven/plugins/invoker/InvokerPropertiesTest.java       | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java 
b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
index 4bf09e7..dff3956 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java
@@ -47,7 +47,7 @@ class InvokerProperties {
     private static final String SELECTOR_PREFIX = "selector.";
 
     private static final Pattern ENVIRONMENT_VARIABLES_PATTERN =
-            
Pattern.compile("invoker\\.environmentVariables\\.([A-Za-z][^.]+)(\\.(\\d+))?");
+            
Pattern.compile("invoker\\.environmentVariables\\.([A-Za-z_][^.]*)(\\.(\\d+))?");
 
     // default values from Mojo configuration
     private Boolean defaultDebug;
diff --git 
a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java 
b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
index c6cd218..86037ac 100644
--- a/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
+++ b/src/test/java/org/apache/maven/plugins/invoker/InvokerPropertiesTest.java
@@ -427,6 +427,20 @@ class InvokerPropertiesTest {
         verifyNoMoreInteractions(request);
     }
 
+    @Test
+    void configureEnvironmentVariablesWithUnderscoreAndSingleLetterNames() {
+        Properties props = new Properties();
+        InvokerProperties facade = new InvokerProperties(props);
+
+        props.setProperty("invoker.environmentVariables._JAVA_OPTIONS", 
"-Dabc=def");
+        props.setProperty("invoker.environmentVariables.X", "x");
+        props.setProperty("invoker.environmentVariables.X.1", "x1");
+        facade.configureInvocation(request, 1);
+        verify(request).addShellEnvironment("_JAVA_OPTIONS", "-Dabc=def");
+        verify(request).addShellEnvironment("X", "x1");
+        verifyNoMoreInteractions(request);
+    }
+
     @Test
     void configureUpdateSnapshots() {
         Properties props = new Properties();

Reply via email to