-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Affected version
4.0.0-rc-4
Expected behavior
When the POM references ${revision}, the resolved value of ${revision} should determine the project version, including cases where ${revision} is set or overridden in a profile.
Observed behavior
${revision} is resolved correctly, but its value is not applied to the final project version.
Steps to reproduce
Execute the provided pom.xml file
Case 1: No profile activated
Expected final version includes "+dev"
$ mvn clean
...
[INFO] Building m4-demo-revision 0.2.0+dev
...
baseVersion : 0.2.0
revision : 0.2.0+dev
project.version: 0.2.0+dev
version : 0.2.0+dev
Case 2: Release profile activated
Expected final version is only baseVersion without "+dev"
$ mvn clean -PreleaseBuild
...
[INFO] Building m4-demo-revision 0.2.0+dev
...
baseVersion : 0.2.0
revision : 0.2.0
project.version: 0.2.0+dev
version : 0.2.0+dev
Case 3: Manipulation profile activated (setting ${version} directly)
${version} is set directly and the change is applied, but it still does not affect the final project version
$ mvn clean -PmanipulateVersion
...
[INFO] Building m4-demo-revision 0.2.0+dev
...
baseVersion : 0.2.0
revision : 0.2.0+dev
project.version: 0.2.0+dev
version : 0.2.0
Note: This is not the intended use case, but maybe it is a hint what's going on here, since it is possible to set the shorthand property ${version}, which then differs from ${project.version}.
Environment
Maven : 4.0.0-rc-4 (bed0f81)
Java : 25.0.0, Azul Systems, Inc.
Locale: en_DE, UTF-8
OS : macOS 15.6.1 (aarch64)
Related Issue
This behavior was also observed during Maven 4.0.0-rc-3 evaluation
[MNG-8694] Version not augmentable during runtime in Maven 4 as it was in Maven 3 (#10394)
Demonstration pom.xml file
<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 http://maven.apache.org/xsd/maven-4.1.0.xsd"
root="true">
<modelVersion>4.1.0</modelVersion>
<groupId>de.g667.m4-demo</groupId>
<artifactId>m4-demo-revision</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<baseVersion>0.2.0</baseVersion>
<revision>${baseVersion}+dev</revision>
</properties>
<profiles>
<profile>
<id>releaseBuild</id>
<properties>
<revision>${baseVersion}</revision>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<id>reportReleaseProfile</id>
<goals>
<goal>echo</goal>
</goals>
<phase>clean[1]</phase>
<configuration>
<message>
Release profile activated
Expected Version: 0.2.0
</message>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>manipulateVersion</id>
<properties>
<version>${baseVersion}</version>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<id>reportReleaseProfile</id>
<goals>
<goal>echo</goal>
</goals>
<phase>clean[1]</phase>
<configuration>
<message>
Manipulating version
Expected Version: 0.2.0
</message>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<version>2.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>4.0.0-beta-2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<id>reportVersions</id>
<goals>
<goal>echo</goal>
</goals>
<phase>clean[2]</phase>
<configuration>
<message>
baseVersion : ${baseVersion}
revision : ${revision}
project.version: ${project.version}
version : ${version}
</message>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>