-2

We have many Maven projects, and one of these projects is included as a dependency in every other project. The problem is, that when deploying a new version of this dependency used by the others, every project gets this new version, which could lead to problems.

Of course, I could manually change the version every time I deploy the project, but that could lead to problems as well, i.e. when forgetting to change the version before deploying it.

I also saw the solution of using a ${version} placeholder in the "version"-tag, but that would mean, that I have to specify the version every time I'm doing a Maven command.

Is there a solution for such problems, where you have a dependency used in many other projects and need a different version in everyone of these projects?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 4
    Why does _when deploying a new version of this dependency used by the others, every project gets this new version"_ happen? How do your Maven projects manage their versions? – Mark Rotteveel Jun 30 '22 at 07:58
  • 2
    `every project gets this new version` -> only if you are not versioning. If you always deploy with version 1.0.0, then it replaces the previously available 1.0.0 version. If you instead increase the version to 1.0.1, then the others will stay with 1.0.0 (given you have specified the version in the other projects) – XtremeBaumer Jun 30 '22 at 07:59
  • Use the maven release plugin. Then you can't easily forget to use a new version. – tgdavies Jun 30 '22 at 08:10

1 Answers1

0

The first thing I see

The problem is, that when deploying a new version of this dependency used by the others, every project gets this new version, which could lead to problems.

This shows a big issue. You seemed to be violating the foundational rule of immutable releases.

In consequence, the version is in the end useless because it's always the same and does not transport any kind of information.

There is first to say you should follow semantic versioning. Also you should use either maven-release-plugin to increment the numbers automatically (but that will not solve the issue minor or major release), there are tools to identify such things). This should be solved by using a CI/CD setup (Jenkins, etc.).

Tools to check changes (compatibility) are things like RevAPI or JAPI-Checker etc. Also some useful information here.

Furthermore you can do that via different setups The mentioned ${version} is simply wrong and will not work in several ways.

Upgrading a larger number of projects can be done by using something like Renovate or things like Dependabot or even some existing Maven plugins which can be run via CI/CD automatically (scheduled) which you should even do for security scans etc. That means automation is the keyword here.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
khmarbaise
  • 92,914
  • 28
  • 189
  • 235