You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/06/16 16:45:55 UTC

(maven) branch cherry-pick-12053-to-maven-4.0.x created (now 3cdda2a6e1)

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

gnodet pushed a change to branch cherry-pick-12053-to-maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git


      at 3cdda2a6e1 Fix #12052: tokenize arithmetic operators as delimiters in ConditionParser (#12053)

This branch includes the following new commits:

     new 3cdda2a6e1 Fix #12052: tokenize arithmetic operators as delimiters in ConditionParser (#12053)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven) 01/01: Fix #12052: tokenize arithmetic operators as delimiters in ConditionParser (#12053)

Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch cherry-pick-12053-to-maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 3cdda2a6e160c6ef3ef3b8eb15de41ca7dec3f4f
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jun 16 18:45:14 2026 +0200

    Fix #12052: tokenize arithmetic operators as delimiters in ConditionParser (#12053)
    
    The tokenizer did not recognize `-`, `*`, `/` as delimiter characters,
    so expressions like `5-3` or `6*4` (without spaces) were tokenized as
    single tokens and failed to parse.
    
    Co-authored-by: Claude Opus 4.6 (1M context) <no...@anthropic.com>
---
 .../org/apache/maven/impl/model/profile/ConditionParser.java |  3 +++
 .../apache/maven/impl/model/profile/ConditionParserTest.java | 12 ++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
index 2f6a075f87..4b73b5217e 100644
--- a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
+++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java
@@ -134,6 +134,9 @@ private List<String> tokenize(String expression) {
                     || c == ')'
                     || c == ','
                     || c == '+'
+                    || c == '-'
+                    || c == '*'
+                    || c == '/'
                     || c == '>'
                     || c == '<'
                     || c == '='
diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
index 990af0d7e3..be1da09919 100644
--- a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
+++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionParserTest.java
@@ -242,6 +242,18 @@ void testArithmeticFunctions() {
         assertEquals(2.5, parser.parse("5 / 2"));
     }
 
+    @Test
+    void testArithmeticWithoutSpaces() {
+        assertEquals(5.0, parser.parse("2+3"));
+        assertEquals(10.0, parser.parse("15-5"));
+        assertEquals(24.0, parser.parse("6*4"));
+        assertEquals(3.0, parser.parse("9/3"));
+        assertEquals(14.0, parser.parse("2+3*4"));
+        assertEquals(20.0, parser.parse("(2+3)*4"));
+        assertEquals(-5.0, parser.parse("-5"));
+        assertEquals(-5.0, parser.parse("-(2+3)"));
+    }
+
     @Test
     void testCombinedArithmeticAndLogic() {
         assertTrue((Boolean) parser.parse("(5 > 3) && (10 / 2 == 5)"));