Skip to content

Maven 4 consumer pom does not carry over mvn xml namespace #11760

Description

@stevenschlansker

Affected version

4.0.0-rc-5

Bug description

I am attempting to upgrade a project to Maven 4. The project includes a build parent pom, which is a sibling module to others that use the parent.

jdbi/
  pom.xml
  jdbi-build-parent/
    pom.xml
  jdbi-core/
    pom.xml (inherit build-parent)
    src/...
  jdbi-other-integration/...

The build parent pom itself inherits from a generic template pom ( basepom )
In order to combine e.g. compiler arguments in our build parent and basepom, in our build parent we declare:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvn="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
            <execution>
                <id>default-compile</id>
                <configuration>
                    <compilerArgs mvn:combine.children="append">
                        <arg>-Xlint:deprecation</arg>
                        <arg>-Xlint:unchecked</arg>
                    </compilerArgs>
                </configuration>
            </execution>
    </plugin>
...

We added the mvn namespace since it seemed to be the upgrade path from the old combine.children directive.

When building the multi-module project, all is well.

% mvn clean install
...
[INFO] BUILD SUCCESS

However, if you then try to use an individual project alone, without the full reactor build, you get a surprising error:

% mvn test -pl :jdbi-other-integration
...

[WARNING] The POM for org.jdbi:jdbi-core:jar:tests:4.0.0-SNAPSHOT is invalid, transitive dependencies (if any) will not be available: 1 problem was 
    - [FATAL] Non-parseable POM org.jdbi:jdbi-build-parent:4.0.0-SNAPSHOT: Unable to read model: Undeclared namespace prefix "mvn" (for attribute "combine.children")
 at [row,col {unknown-source}]: [786,64]

...

[ERROR] org.jdbi.guava.codec.TypeResolvingCodecFactoryTest.testCollectionCodec -- Time elapsed: 0.101 s <<< ERROR!
java.lang.NoClassDefFoundError: io/leangen/geantyref/GenericTypeReflector

Sure enough, the installed consumer pom lost the xmlns:mvn on the opening <project> tag:

% head ~/.m2/repository/org/jdbi/jdbi-build-parent/4.0.0-SNAPSHOT/jdbi-build-parent-4.0.0-SNAPSHOT.pom 
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

So it looks like Maven, while transforming our build parent pom into its consumer version for installation to the local repository, drops the <project xmlns:mvn declaration and then writes an invalid POM file to the local repo.

The source is available, although it's not a minimal example: jdbi/jdbi#2935

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions