Skip to content

Mvnup breaks projects using a META-POM #7934

Open
@Bukama

Description

@Bukama

Affected version

4.0.0-rc4

Bug description

The Maven Upgrade tool introduced in #2407 breaks projects, which are using an external META-POM as it removes the parents groupId and artifactId - which is not needed in subprojects with the parent in the same project / reactor.

Example from a small reproducer I've created for a PMD issue. The META-POM is an external POM project providing the same build instructions for other projects.

<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
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.test.mpmd386</groupId>
    <artifactId>SingleModuleRoot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Single Module Root</name>

    <parent>
        <groupId>my.test.mpmd386</groupId>
        <artifactId>META-POM</artifactId>
        <version>1.0.0</version>
    </parent>

    <properties>
      <path.to.suppressfile.wo.slash>${project.basedir}</path.to.suppressfile.wo.slash>
    </properties>
</project>

results in

<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">
    
    <artifactId>SingleModuleRoot</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>Single Module Root</name>

    <parent>
        <version>1.0.0</version>
    </parent>

    <properties>
      <path.to.suppressfile.wo.slash>${project.basedir}</path.to.suppressfile.wo.slash>
    </properties>
</project>

Notice:

  • <modelVersion> is gone (wonders me)
  • groupId and artifactIdwere also deleted
  • (not .mvn folder was created

This now results in

D:\Github\mpmd386\PMD_314\SingleModuleRoot>mvn clean verify
[INFO]
[INFO] 1 problem was encountered while building the effective settings (use -e to see details)
[INFO]
[WARNING] Unable to find the root directory. Create a .mvn directory in the root directory or add the root="true" attribute on the root project's model to identify it.
[INFO] Scanning for projects...
[ERROR] Some problems were encountered while processing the POMs
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project (D:\Github\mpmd386\PMD_314\SingleModuleRoot\pom.xml) has 3 errors
[ERROR] 'parent.groupId' is missing. @ [unknown-group-id]:SingleModuleRoot:0.0.1-SNAPSHOT, file:///D:/Github/mpmd386/PMD_314/SingleModuleRoot/pom.xml, line 9, column 5
[ERROR] 'parent.artifactId' is missing. @ [unknown-group-id]:SingleModuleRoot:0.0.1-SNAPSHOT, file:///D:/Github/mpmd386/PMD_314/SingleModuleRoot/pom.xml, line 9, column 5
[ERROR] Failed to load project D:\Github\mpmd386\PMD_314\SingleModuleRoot\pom.xml: 2 problems were encountered while building the effective model
[ERROR] - [FATAL] 'parent.groupId' is missing. @ line 9, column 5
[ERROR] - [FATAL] 'parent.artifactId' is missing. @ line 9, column 5
[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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions