Repository navigation
Description
Tom Kiemes opened MNG-6727 and commented
We would like to pass a version range to the parent which should be possible since 3.5.0
At the same time, we would like to use CI friendly versions for the artifact itself.
Both on their own work well, but combined they don't.
<?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] [http://maven.apache.org/xsd/maven-4.0.0.xsd]">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>[2.1,3.0)</version>
</parent>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<revision>0.0.1</revision>
</properties>
</project>
The resulting error is:
The project com.example:test:${revision} (/Users/d045390/scratch/test.pom) has 1 error
[ERROR] Version must be a constant @ line 13, column 12
Changing the version range of the parent to a fixed version e.g. 2.1.5.Release, building works.
Changing the artifact version from ${revision} to a fixed version e.g. 0.0.1 without using the properties works as well.
So it somehow must be the combination of both features which are actually not really related or am I missing something?
PS: I left the modules out for abbreviation purpose. The pom itself can still be used to reproduced
Affects: 3.5.2, 3.6.1, 3.6.2, 3.6.3
Remote Links:
Backported to: 4.0.0-alpha-2, 3.8.5
4 votes, 10 watchers
Activity
jira-importer commentedon Aug 20, 2019
Vasiliy commented
I ran into same issue. Any solutions?
We have a multirepo, multi module project. All repos derive from a single pom repo called "top" and versions are all over the pom files. I am trying to avoid static versions in pom files and use $revision. However, if I use$revision inside the parent section of a deriving repo's pom.xml (this not a multimodule repo), mvn is trying to resolve top-$ {revision} (literally) instead of top-1.0.0 (i used mvn -Drevision=1.0.0 clean install).
Since that didnt work, I tried to fix the top's version as a fixed range and ran into above issue, where $revision and range does not work together.
Either way I am unable to avoid putting static version numbers in all our pom files.
Any help appreciated.
jira-importer commentedon Nov 27, 2019
Karl Heinz Marbaise commented
Based on MNG-2199 this has been fixed with Maven 3.5.0-alpha,3.5.0. The error message looks like using an older version of Maven not one which able to handle revision property for version tags?.
jira-importer commentedon Nov 28, 2019
Thorsten Meinl commented
I can confirm that this is still an issue with 3.6.x.
jira-importer commentedon Nov 30, 2019
Karl Heinz Marbaise commented
Unfortunately I have to confirm that as well.
jira-importer commentedon Oct 22, 2020
Ralf commented
Yes. "Unfortunately I have to confirm that as well."
Too much time spend finding out what the issue actually is. Searching the problem in my poms. Both features work fine for themselves. The parent version range and cli friendly versions - but once you combine them - your screwed. I have no real solution :(
The only work around I found in a multi module project - when I'm not interested in the parent-artifacts anyways - that I set the parent version to a fixed SNAPSHOT like "dev-SNAPSHOT" and only apply the correct ${revision} to the child modules. Not very elegant and not a solution for single module projects...
jira-importer commentedon Dec 29, 2020
Jeff Maxwell commented
I believe the root causes is this section
The code attempts to prevent parent version ranges being used as the child version, which is a good thing, but the solution, checking if the child version starts with ${ breaks the combined usage of parent version ranges and property based versions.
Can this check just be replaced with a check if the version is set via either
${project.version} or${project.parent.version}?Or can the contents of the
childModel.getVersion()be evaluated at this point and checked if the value is truly a version range?jira-importer commentedon Dec 29, 2020
Michael Osipov commented
Is the issue still observed with Maven from master?
jira-importer commentedon Dec 30, 2020
Jeff Maxwell commented
I believe I have this resolved in the PR. Can this be back ported to 3.6.x?
jira-importer commentedon Jan 6, 2021
Jeff Maxwell commented
Resubmitted the PR, hopefully it will pass all jdk ITs.
I have added additional test coverage.
jira-importer commentedon Jan 6, 2022
Michael Osipov commented
Jeff Maxwell, one year has passed, today is my birthday again and make me a present: Take a look at my comments on the PR and I will review and merge.
jira-importer commentedon Feb 1, 2022
Guillaume Nodet commented
Fixed with d79485ff23c9017d47424ff24da1d6dd3c414a60 and 1d473233f21b63f351ded6904f4f9f98db3faaf1