Maven artifact version for patches

2020-05-29 04:22发布

问题:

I'm currently working on Maven tools for Project Dash. One of the open issues is how to handle mistakes.

Maven central says: Nothing published ever changes. This is because Maven never tries to figure out whether a release has changed (unlike for SNAPSHOTs).

But I might have to create a new "release" of, say, part of Eclipse 3.6.2. Which version number should I use? 3.6.2.1, 3.6.2-1, 3.6.2_1, 3.6.2pl1? Why?

回答1:

The convention for version numbers is major.minor.build.

major is incremented when the public interface changes incompatibly. For example, a method is removed, or its signature changes. Clients using your library need to take care when using a library with a different major version, because things may break.

minor is incremented when the public interface changes in a compatible way. For example, a method is added. Clients do not need to worry about about using the new version, as all the functions they are used to seeing will still be there and act the same.

build is incremented when the implementation of a function changes, but no signatures are added or removed. For example, you found a bug and fixed it. Clients should probably update to the new version, but if it doesn't work because they depended on the broken behavior, they can easily downgrade.

The tricky issue here is that it sounds like you are modifying code written and released by somebody else. The convention here, as I have seen it, is to postfix the version number with either -yourname-version or just -version. For example, linux-image-2.6.28-27 is a likely name of a Ubuntu kernel image.

As Maven uses dashes to differentiate between artifact coordinates, however, I would recommend (very long-windedly, apparently) to just add .version to avoid confusing it. So 3.6.2.1 in this case.



回答2:

Maven project versions are specified like this.

<major version>.<minor version>.<incremental version>-<qualifier>

As you do not want to change the version number you are looking for a qualifier. I do not know if there is a general recommendation for the name of the qualifier. The Spring people e.g. did something like this

2.5.6.SEC01
2.5.6.SR02
3.0.0.M3

They didn't use the hyphen/dash notation to seperate the qualifier.

What ever you do, you have to be careful regarding the ordering of versions! Have a look at the first link I added.

Update: Also have a look at @krzyk comment for recent changes/additions.



回答3:

This is because Maven never tries to figure out whether a release has changed

That's in my opinion not the basic reason. The reason is to have reliable builds in the future. You define the versions in your pom and that's it. If someone would remove artifacts from maven central or become worse changing an existing artifact you can't be sure that your build will be working in the future...or an older build would work.

The version number is up to you...i would suggest to use 3.6.2.1.