Why does Maven 3 give up supporting application $version declaration?

17,137

Solution 1

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.

Solution 2

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.

Share:
17,137
javatar
Author by

javatar

Programmer, Researcher&amp;Instructor, Engineering Manager/Director, Clean code &amp; Open Source lover https://www.linkedin.com/in/bariscangungor/ https://www.originium.com/

Updated on June 03, 2022

Comments

  • javatar
    javatar almost 2 years

    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?

  • javatar
    javatar almost 14 years
    I am talking about <version>${projectVersion}</version> declaration. Instead of, say, writing the version like <version>0.0.1</version> 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?
  • Artem
    Artem almost 14 years
    In what content? In an ordinary dependency or inside <parent>?
  • khmarbaise
    khmarbaise almost 14 years
    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?
  • javatar
    javatar almost 14 years
    Hi again, here it is what inside of the top pom.xml; <modelVersion>4.0.0</modelVersion> <groupId>com.mp.myproject</groupId> <artifactId>myproject</artifactId> <name>myproject Maven Main</name> <packaging>pom</packaging> <properties> <projectVersion>2.3</projectVersion> </properties> <version>${projectVersion}</version> ... <modules> <module>../myproject_domain</module> <module>../myproject_ejb</module> <module>../myproject_web</module> <module>../myproject_ear</module> </modules>
  • javatar
    javatar almost 14 years
    Ok, and the other pom.xml's in the modules there are: <parent> <artifactId>myproject</artifactId> <groupId>com.mp.myproject</groupId> <version>${projectVersion}</version> <relativePath>../myproject/pom.xml</relativePath> </parent>