0

This is a 'best practice' question.

Projects are build using maven and jenkins.

The target project release version is set via maven, for example:

set-version -DnewVersion=13.3.0

So the build doesn't use the version tag from the pom.xml, in this case version in the pom seems useless...

Is it a wrong way to build our projects ? Is there a best practice about this ?

Tyvain
  • 2,040
  • 4
  • 25
  • 55

2 Answers2

1

I think many people nowadays don't have much of a use of the version inside POM. You could still increment it from time to time to denote some new epoch in your project, but that's more of a marketing thing.

If you're planning to do Continuous Delivery you'll find that any release version (including your manual way) will violate one of the cornerstones of CD: only the artifacts that pass the pipeline are releasable. But you don't know if it's releasable until it passes the pipeline so you can't set the release version beforehand. Eventually you may find yourself using only SNAPSHOT versions. Of course you'll have to use a resolved snapshot with the timestamp to reference that particular version.

Stanislav Bashkyrtsev
  • 11,403
  • 7
  • 33
  • 38
0

The version number in the POM file is not useless, but it certainly is under some pressure while many organizations transition to flavors of Continuous Delivery (as you funnel commits, branches, and then some anointed branches like develop through levels of increasing scrutiny (CI, QA), you may not necessarily have release versions separate from SNAPSHOT versions).

The best practice for releasing Maven projects is to use the Maven Release Plugin. It will prepare the release (e.g. 13.3.0), tag the release (13.3.0), and prepare for the next development iteration (e.g. 13.3.1-SNAPSHOT). During the development iteration SNAPSHOT versions (e.g. 13.3.1-SNAPSHOT) are scattered around with no expectation of reproducibility. These versions may not even be VCS-committed, or they are be on branches that may still be squashed out of existence, later. The version in the POM file is thus useful because it always declares what version you're looking at (in your VCS). Using the Maven Release Plugin helps you to warrant that there's not two releases with the same version (e.g. 13.3.0).

Also note that if you're distinguishing between build and consumer POMs, the latter is used to depend on an artifact, and the dependent project needs to express the version number to match that of the dependency's POM file.

Sander Verhagen
  • 6,528
  • 4
  • 32
  • 59
  • I don't think using Maven Release Plugin is best practice anymore. In CD it becomes pretty useless. And it was cumbersome and inconvenient even before. – Stanislav Bashkyrtsev Mar 26 '18 at 06:59
  • There is still many projects that have low velocity of releases where this still works best, and for which the investment in CD does not pay off. But I don't entirely disagree with you, I think I acknowledged that in my first paragraph, but for me it's one of those "that depends". The original question though suggested that they were aiming at specific releases, though it wasn't entirely clear. – Sander Verhagen Mar 27 '18 at 05:12