stevenschlansker opened a new issue, #11760:
URL: https://github.com/apache/maven/issues/11760

   ### 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](https://basepom.org/) )
   In order to combine e.g. compiler arguments in our build parent and basepom, 
in our build parent we declare:
   ```xml
   <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: 
https://github.com/jdbi/jdbi/pull/2935
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to