Search code examples
maven-2versioningversionmavenmaven-3

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?


Solution

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