Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-8306

Fix wrong order in merged xml nodes and double profile injection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0-beta-4
    • 4.0.0-beta-5
    • Profiles
    • None

    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

        1. pom.xml
          0.9 kB
          Daniel Schmid
        2. job-logs.txt
          151 kB
          Daniel Schmid

        Issue Links

          Activity

            People

              gnodet Guillaume Nodet
              dan1st Daniel Schmid
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: