Daniel Schmid created MNG-8306:
----------------------------------

             Summary: combine.children=append duplicating options
                 Key: MNG-8306
                 URL: https://issues.apache.org/jira/browse/MNG-8306
             Project: Maven
          Issue Type: Bug
          Components: Profiles
    Affects Versions: 4.0.0-beta-4
         Environment: Apache Maven 4.0.0-beta-4 
(697c543b4e3bbec1b99e9d4d1ee8e0302e748f09)
Maven home: /home/dan1st/dev/tools/maven
Java version: 21.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/graal21
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.11.0-8-generic", arch: "amd64", family: "unix"
            Reporter: Daniel Schmid
         Attachments: job-logs.txt, pom.xml

if a combine.children="append" is set in some profile on an element with 
multiple children, these children are duplicated.

For example, if <compilerArgs> is set with combine.children="append" for the 
maven-compiler-plugin in a profile with
{code:java}
<arg>-Xmaxerrs</arg>
<arg>100</arg>
<arg>-Xmaxwarns</arg>
<arg>100</arg> {code}
then executing the build with that profile results in the following CLI 
arguments for javac:

 
{code:java}
[DEBUG] Command line options:
[DEBUG] -d /home/runner/work/maven-repro/maven-repro/target/classes -classpath 
/home/runner/work/maven-repro/maven-repro/target/classes: -sourcepath 
/home/runner/work/maven-repro/maven-repro/src/main/java:/home/runner/work/maven-repro/maven-repro/target/generated-sources/annotations:
 -s 
/home/runner/work/maven-repro/maven-repro/target/generated-sources/annotations 
-g --release 17 -encoding UTF-8 -Xmaxerrs 100 100 -Xmaxwarns -Xmaxerrs 100 
-Xmaxwarns 100 -XDuseUnsharedTable=true{code}
 

 

Since javac doesn't know what to do with "-Xmaxerrs 100 100", it fails to build.

 

An example of such a profile would be the following:
{code:java}
        <profile>
            <id>test</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.13.0</version>
                        <configuration>
                            <compilerArgs combine.children="append">
                                <arg>-Xmaxerrs</arg>
                                <arg>100</arg>
                                <arg>-Xmaxwarns</arg>
                                <arg>100</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile> {code}
If a project like that is run with
{code:java}
mvn clean verify -Ptest {code}
 on Maven 4, this will result in the above CLI arguments and a build failure.

Both the full pom.xml as well as the build output are included as attachments.

A full reproducer using GitHub Actions can be found here: 
[https://github.com/danthe1st/maven-repro/tree/duplicate-compiler-arg]
Build output: 
[https://github.com/danthe1st/maven-repro/actions/runs/11280962017/job/31375110882]
Build output with Maven 3 (works): 
[https://github.com/danthe1st/maven-repro/actions/runs/11280962017/job/31375110610]

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to