Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Easier maintenance of <version> in large projects

Motivation

If you develop a large project with maven, you will typically split your code into various modules organized in a large tree (POM hierarchy). Maven is a great tool to support the development of such project. However there is a major drawback addressed in this toppic:

Every node in your POM hierarchy has a pom.xml with a groupId, artifactId and a version. Besides you have references to other POMs (or artifacts - however you see it) in your pom:

  • The <parent> section will point to parent project.
  • The <dependency> sections will point to dependent artifacts.

Now the problem is about those references that point to POMs of your own project. Those will typically have the same <groupId> and <version> as the one defined in the referenced pom. For <groupId> the solution is simply to use <groupId>${project.groupId}</groupId> but your groupId will normaly never change anyhow. But on the other hand the <version> will change often and this becomes a maintenance problem if you have to spread the versions of your artifacts all over the POMs.

So following the maven concept "convention over configuration" maven should offer a way to express a project-internal reference that points to the current version of that module defined in pom.xml without explicitly knowing this version. The suggestion is to be able to omit the version in such case. This would allow to have the version as a single point of information in the according pom while references still have the chance to explicitly specify a (older) version.

Two views on a POM

At this point we have to distinguish that there are two different points of view when maven is looking at a POM:

  • For development of a project maven reads pom.xml files from the local disc.
  • For using artifacts that have already been deployed (or installed) maven retrieves *.pom files from a repository (in the end from local repository).

An important issue for a new maven feature is that it is compatible with other maven versions and therefore will NOT break existing builds in any way. Therefore the suggested feature is planned to be only visible for the development view. To archieve this goal, maven has to be changed in a way such that it automatically adds omitted <version> tags in POMs that are installed in or deployed to a repository. To avoid mistakes or missusage of such feature maven could also reject processing POMs with missing <version> tag, that are not read as pom.xml but retrieved from a repository (including local repo).

The solution in detail



  • No labels