maven release plugin with parameterized version

The plugin currently doesn't support parameterized versions from parent (tried v2.2.2 as well). The solution was to use {project.version}.


TL;DR: Accepted answer does not help; Known defect in maven-release-plugin; New CI-Friendly versions in maven 3.5 help somewhat (but don't really solve the OPs issue)

Long version:

The accepted answer doesn't work. I experimented and found the results commented by @Dormouse. Adding this answer for more clarification:

Prefixing the variable name with "project." gets maven release:prepare past the original error, but it will update the version of the custom-versioned module to match all the others

So, as @Dormouse states, the property is useless because after the first maven release call it will no longer refer to the correct version of the module.

For example - some excerpts from a demonstration:

parent pom.xml:

<version>1.0-SNAPSHOT</version>
<properties>
    <!-- note the custom property starts with "project" to pass release:prepare -->
    <project.version.custom>1.2-SNAPSHOT</project.version.custom>
</properties>
<modules>
    <module>custom-versioned-module</module>
    <module>dependent-module</module>
</modules

custom-versioned-module/pom.xml:

<parent>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>custom-versioned-module</artifactId>
<!-- this module has 1.2-SNAPSHOT instead of 1.0-SNAPSHOT like the rest -->
<version>1.2-SNAPSHOT</version>

dependent-module/pom.xml

<parent>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>dependent-module</artifactId>
<dependencies>
    <dependency>
        <artifactId>custom-versioned-module</artifactId>
        <!-- experiment with variable version -->
        <version>${project.version.custom}</version>
    </dependency>
 </dependencies>

Now try mvn release:prepare -DdryRun=true and examine the files created. (You can see what the release:perform would do by looking at pom.xml.next - this is used to replace pom.xml if you do not use -DdryRun)

You will see that the version property is left intact, as is the dependency (we wouldn't expect the maven-release-plugin to mess with those), but the actual version of custom-version-module is changed!

custom-versioned-module/pom.xml.next:

<parent>
    <version>1.1-SNAPSHOT</version>
</parent>
<artifactId>custom-versioned-module</artifactId>
<version>1.1-SNAPSHOT</version>

The parent version is increased from 1.0 to 1.1, but the module version is decreased from 1.2 to 1.1 (it's simply made the same, not specifically decremented)

Meanwhile the property itself remains at 1.2 so if you actually release, the next build will fail.

Note that this is logged as maven defect here: https://issues.apache.org/jira/browse/MRELEASE-782

And it is somewhat mitigated by the CI-Friendly versioning in 3.5:

https://maven.apache.org/maven-ci-friendly.html