Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.0-beta-4
-
None
-
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"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"
Description
if 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
<arg>-Xmaxerrs</arg> <arg>100</arg> <arg>-Xmaxwarns</arg> <arg>100</arg>
then executing the build with that profile results in the following CLI arguments for javac:
[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
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:
<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>
If a project like that is run with
mvn clean verify -Ptest
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
Attachments
Attachments
Issue Links
- links to