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

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e288b51df Fix multiline profile activation conditions (#12136)
3e288b51df is described below

commit 3e288b51dfd9f8e3dcf72c5e0caffb31f2c9a57f
Author: Silva Dev BR <[email protected]>
AuthorDate: Tue Jun 16 13:25:53 2026 -0300

    Fix multiline profile activation conditions (#12136)
    
    * Fix multiline profile activation conditions
    
    * Address condition parser operator style nit
    
    ---------
    
    Co-authored-by: Guillaume Nodet <[email protected]>
---
 .../maven/impl/model/ComplexActivationTest.java    | 14 +++++++++++
 .../profile/ConditionProfileActivatorTest.java     | 19 +++++++++++++++
 .../resources/poms/factory/multilineCondition.xml  | 27 ++++++++++++++++++++++
 3 files changed, 60 insertions(+)

diff --git 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ComplexActivationTest.java
 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ComplexActivationTest.java
index eed8b9fa5a..94f0f766e2 100644
--- 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ComplexActivationTest.java
+++ 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/ComplexActivationTest.java
@@ -67,6 +67,20 @@ void testAndConditionInActivation() throws Exception {
         
assertNull(result.getEffectiveModel().getProperties().get("profile.miss"));
     }
 
+    @Test
+    void testMultilineConditionInActivation() throws Exception {
+        ModelBuilderRequest request = ModelBuilderRequest.builder()
+                .session(session)
+                .requestType(ModelBuilderRequest.RequestType.BUILD_PROJECT)
+                .source(Sources.buildSource(getPom("multilineCondition")))
+                .systemProperties(Map.of("gh11882.left", "true", 
"gh11882.right", "true"))
+                .build();
+        ModelBuilderResult result = builder.newSession().build(request);
+        assertNotNull(result);
+        assertNotNull(result.getEffectiveModel());
+        assertEquals("activated", 
result.getEffectiveModel().getProperties().get("profile.condition"));
+    }
+
     @Test
     public void testConditionExistingAndMissingInActivation() throws Exception 
{
         ModelBuilderRequest request = ModelBuilderRequest.builder()
diff --git 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
index 5d371c2fc3..a47ffc3225 100644
--- 
a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
+++ 
b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/ConditionProfileActivatorTest.java
@@ -284,6 +284,25 @@ void testOsAllConditions() {
         assertActivation(true, profile, newContext(null, 
newOsProperties("windows", "99", "aarch64")));
     }
 
+    @Test
+    void testMultilineLogicalAndCondition() {
+        Profile profile = newProfile("""
+                ${os.name} == 'windows'
+                && ${os.arch} != 'amd64'
+                && inrange(${os.version}, '[99,)')""");
+
+        assertActivation(false, profile, newContext(null, 
newOsProperties("linux", "6.5.0-1014-aws", "amd64")));
+        assertActivation(false, profile, newContext(null, 
newOsProperties("windows", "1", "aarch64")));
+        assertActivation(false, profile, newContext(null, 
newOsProperties("windows", "99", "amd64")));
+        assertActivation(true, profile, newContext(null, 
newOsProperties("windows", "99", "aarch64")));
+    }
+
+    @Test
+    void testLogicalOperatorsWithWhitespace() {
+        assertActivation(true, newProfile("false\r\n||\ttrue"), 
newContext(null, null));
+        assertActivation(false, newProfile("true\r\n&&\tfalse"), 
newContext(null, null));
+    }
+
     @Test
     public void testOsCapitalName() {
         Profile profile = newProfile("lower(${os.name}) == 'mac os x'");
diff --git 
a/impl/maven-impl/src/test/resources/poms/factory/multilineCondition.xml 
b/impl/maven-impl/src/test/resources/poms/factory/multilineCondition.xml
new file mode 100644
index 0000000000..3f7027429d
--- /dev/null
+++ b/impl/maven-impl/src/test/resources/poms/factory/multilineCondition.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.1.0</modelVersion>
+
+    <groupId>test</groupId>
+    <artifactId>test</artifactId>
+    <version>0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <profiles>
+        <profile>
+            <id>multiline-condition</id>
+            <activation>
+                <condition><![CDATA[
+                    ${gh11882.left} == 'true'
+                    && ${gh11882.right} == 'true'
+                ]]></condition>
+            </activation>
+            <properties>
+                <profile.condition>activated</profile.condition>
+            </properties>
+        </profile>
+    </profiles>
+</project>

Reply via email to