Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 830
javatar Avatar asked May 13 '10 12:05

javatar


2 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.

like image 163
Pascal Thivent Avatar answered Nov 08 '22 17:11

Pascal Thivent


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.

like image 24
bmargulies Avatar answered Nov 08 '22 19:11

bmargulies