Search code examples
mavenpropertiesscopemaven-2maven-3

Maven ${project.version} scope


I have parent pom with dependency management declared by ${project.version}. Then I inherit parent in my target project, this project has other version than parent.

This throws errors, because of dependencies declared in parent was looked for by version of target project instead of parent version where it was declared.

I used additional property ${parent.version} and I have to remember to change version in two places on upgrade.

I would like use ${project.version} in parent with parent version value and in target project with its value without changing version declared in parent POM.

Can I block scope of ${project.version} to parent only when I use it in parent POM?


Solution

  • No.

    But maybe you can solve the problem with the flatten maven plugin, i.e. replacing the ${project.version} in the parent POM before publishing the parent POM.