In maven multi-module projects where I want each of the modules to always keep the same version as the parent, I\'ve typically done something like the following in the modul
I'm curious to know what the real problem with tying a module's version to the parent version is, if any? Or is this a case of a general warning when any expression, regardless of whether it's project.parent.version, is used for the version element.
Well, that would be easy to test. Because I was curious, I just did it for you using the following pom:
4.0.0
parent
com.mycompany
1.0-SNAPSHOT
com.mycompany
module
${myversion}
module
http://maven.apache.org
1.0-SNAPSHOT
...
And maven is indeed complaining:
[WARNING] 'version' contains an expression but should be a constant. @ com.mycompany:module:${myversion}, /home/pascal/Projects/maven-maven3-testcase/module/pom.xml
To be honest, I think that maven is right here, it doesn't make much sense to use a property for the element (at least not for project.version) and it's nice to have maven complaining about it.
And if you want to use the parent pom version in sub-modules, just remove the tag from the child poms, they will inherit the version from the parent. What you are currently doing is unnecessary.