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

Can't parse project that has <parent> tag in plugin configuration

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.x-candidate
    • 4.0.0-alpha-2, 4.0.0
    • build/consumer
    • None

    Description

      The Apache Camel project has the following snippet in their root POM:

                      <plugin>
                          <groupId>org.codehaus.mojo</groupId>
                          <artifactId>flatten-maven-plugin</artifactId>
                          <version>1.2.5</version>
                          <executions>
                              <execution>
                                  <id>default-cli</id>
                                  <phase>process-resources</phase>
                                  <goals>
                                      <goal>flatten</goal>
                                  </goals>
                                  <configuration>
                                      <!-- snip -->
                                      <pomElements>
                                          <!-- snip -->
                                          <parent>expand</parent>
                                          <!-- snip -->
                                      </pomElements>
                                  </configuration>
                              </execution>
                          </executions>
                      </plugin>
      

      With Maven 4's "Build Consumer" feature enabled, parsing this plugin definition breaks with

      [INFO] BuildTimeEventSpy is registered.
      [INFO] Scanning for projects...
      [ERROR] [ERROR] Some problems were encountered while processing the POMs:
      [FATAL] Unable to transform pom
      [ERROR] The build could not read 1 project -> [Help 1]
      [ERROR]   
      [ERROR]   The project (/Users/maarten/Code/open-source/camel/pom.xml) has 1 error
      [ERROR]     Unable to transform pom: Not a regular file: /Users/maarten/Code/open-source/pom.xml
      [ERROR] 
      [ERROR] To see the full stack trace of the errors, re-run Maven with the '-e' switch
      [ERROR] Re-run Maven using the '-X' switch to enable verbose output
      [ERROR] 
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
      

      I suspect that the <parent> tag is the culprit. It seems to me that it causes the ParentXMLFilter to think it needs to do its work. The attached screenshot shows the stacktrace that brought me to this idea. As the BufferingParser class processes its buffer of events, it encounters a situation of an "end parent tag". But that parent tag did not have child elements version and relativePath and so, it decides it needs to resolve the parent as ../pom.xml against the project path (/Users/maarten/Code/open-source/camel/ in my case), leading to the non-existing path of /Users/maarten/Code/open-source/pom.xml.

      I think the bug here is not that it resolves to a non-existing path (it's good to check that before actually reading the file). I think the bug is that the ParentXMLFilter is acting on the parent tag inside the plugin configuration.

      Attachments

        1. Screenshot 2021-12-13 at 13.45.01.png
          305 kB
          Maarten Mulders

        Issue Links

          Activity

            People

              gnodet Guillaume Nodet
              mthmulders Maarten Mulders
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: