jycr created MNG-7840:
-------------------------
Summary: Maven pom relocation do not work with parent pom
Key: MNG-7840
URL: https://issues.apache.org/jira/browse/MNG-7840
Project: Maven
Issue Type: Bug
Components: Artifacts and Repositories, Dependencies
Affects Versions: 3.9.2
Environment: Apache Maven 3.9.2
(c9616018c7a021c1c39be70fb2843d6f5f9b8a1c)
Java version: 17.0.5, vendor: GraalVM Community
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "13.4.1", arch: "aarch64", family: "mac"
Reporter: jycr
Relocating parent POM do not work.
Reproduce steps:
# Create following POM files :
{code:xml|title=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>
{code}
{code:xml|title=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>
{code}
{code:xml|title=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>
{code}
# Install parent POM files into local cache:
{code:shell}
mvn install -f parent-pom-a.pom
mvn install -f parent-pom-b.pom
{code}
# Execute Maven with {{project-pom.pom}}
{code:shell}
mvn initialize -f project-pom.pom
{code}
Actual result:
{code}
[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] ------------------------------------------------------------------------
{code}
Expected result:
{code}
[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] ------------------------------------------------------------------------
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)