Details
Description
Relocating parent POM do not work.
Reproduce steps:
- Create following POM files :
parent-pom-a.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"> <modelVersion>4.0.0</modelVersion> <groupId>com.acme</groupId> <artifactId>parent-pom-a</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <distributionManagement> <relocation> <groupId>com.acme</groupId> <artifactId>parent-pom-b</artifactId> <version>1.0.0</version> </relocation> </distributionManagement> </project>
parent-pom-b.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"> <modelVersion>4.0.0</modelVersion> <groupId>com.acme</groupId> <artifactId>parent-pom-b</artifactId> <version>1.0.0</version> <packaging>pom</packaging> <properties> <properties-from-parent-pom>b</properties-from-parent-pom> </properties> </project>
project-pom.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"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.acme</groupId> <artifactId>parent-pom-a</artifactId> <version>1.0.0</version> </parent> <artifactId>project-pom</artifactId> <packaging>pom</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.encoding>${project.build.sourceEncoding}</maven.compiler.encoding> <project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding> </properties> <build> <plugins> <plugin> <groupId>com.github.ekryd.echo-maven-plugin</groupId> <artifactId>echo-maven-plugin</artifactId> <version>2.0.0</version> <executions> <execution> <goals> <goal>echo</goal> </goals> <phase>initialize</phase> <configuration> <message>properties-from-parent-pom: ${properties-from-parent-pom}</message> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
- Install parent POM files into local cache:
mvn install -f parent-pom-a.pom mvn install -f parent-pom-b.pom
- Execute Maven with project-pom.pom
mvn initialize -f project-pom.pom
Actual result:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.acme:project-pom >------------------------ [INFO] Building project-pom 1.0.0 [INFO] from project-pom.pom [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] --- echo:2.0.0:echo (default) @ project-pom --- [INFO] properties-from-parent-pom: ${properties-from-parent-pom} [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.145 s [INFO] Finished at: 2023-07-10T09:47:45+02:00 [INFO] ------------------------------------------------------------------------
Expected result:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------< com.acme:project-pom >------------------------ [INFO] Building project-pom 1.0.0 [INFO] from project-pom.pom [INFO] --------------------------------[ pom ]--------------------------------- [WARNING] The artifact com.acme:parent-pom-a:pom:1.0.0 has been relocated to com.acme:parent-pom-b:pom:1.0.0 [INFO] [INFO] --- echo:2.0.0:echo (default) @ project-pom --- [INFO] properties-from-parent-pom: b [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.136 s [INFO] Finished at: 2023-07-10T09:48:52+02:00 [INFO] ------------------------------------------------------------------------