Why does Maven 3 give up supporting application $version declaration?
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
?
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.
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.
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}
精彩评论