As you see from the title, I want to ask that the case of in Maven 3 there is no support for $version
in pom.xml
anymore. Do we have to really write a constant every time in each project in every pom.xml
and related configuration files again and again? How can we avoid doing this? How can we use a versioning method like $version
?
3 Answers
The expression ${version}
is deprecated, you should use ${project.version}
instead, but both are still supported and you certainly don't need a custom property.
The following just works fine for me with Maven 3:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>services</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
And also have a look at my previous answer to Warning on using project.parent.version as the version of a module in Maven 3, the way you're using version
(based on what I saw in the comments in another answer) doesn't make much sense IMHO and Maven 3 actually kindly suggests to follow a best practice. Just inherit the version.

- 1
- 1

- 562,542
- 136
- 1,062
- 1,124
Using a macro inside the top <version/>
element and the version in the <parent/>
element never worked in maven 2. It appeared to work, but caused nothing but confusion downstream. If that's not what you are talking about, please clarify your question.

- 97,814
- 39
- 186
- 310
-
1I am talking about
${projectVersion} declaration. Instead of, say, writing the version like0.0.1 we could write ${projectVersion} before, but in maven3, it does not support it. I understand it from the warning it gives right on the clean-install time. On the console, it clearly says "version must be a constant". However, before maven3 it never warned like that. So, in maven3, the ${projectVersion} declaration (for my example) between the version tags is not supported anymore. As a result, is there any idea or a method that enables me to use it again? – javatar May 13 '10 at 13:03 -
In what content? In an ordinary dependency or inside
? – bmargulies May 13 '10 at 13:17 -
Where is the problem with ${project.version} usually you don't need. If you release a new version it will automatically replace the old versions with the new ones. So i don't see the need for a macro? – khmarbaise May 13 '10 at 13:19
-
Hi again, here it is what inside of the top pom.xml;
4.0.0 com.mp.myproject myproject myproject Maven Main pom 2.3 ${projectVersion} ...../myproject_domain ../myproject_ejb ../myproject_web ../myproject_ear -
Ok, and the other pom.xml's in the modules there are:
myproject com.mp.myproject ${projectVersion} ../myproject/pom.xml
The error below shows the deprecation of $(artifactId}
and ${version}
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead. [WARNING] The expression ${version} is deprecated. Please use ${project.version} instead. [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten t he stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support buildin g such malformed projects.
The warning message spells it out. Replace ${artifactId}
with ${project.artifactId}
, and ${version}
with ${project.version}

- 41
- 3