Hi John,

On 24.11.19 20:46, John Patrick wrote:
i'm trying to start using maven version range more but having issues
with things like guava and also it not excluding version i believe
should be excluded.

1) i don't think this is possible but it might be, take a look a
google guava, it has a jre and a android version. using maven version
range how can i say any newer jre version, or any newer android
version?

https://search.maven.org/artifact/com.google.guava/guava

something like [25,) but only the jre maybe [25*-jre,)


Let us start with Guava.

The issue with Guava is that they made the `-jre` part of the version
number which is from a Maven point of view simply wrong. This should
have been done via a clas^sifier. Because -jre, -android are specialized
packages which are valid for only particular environments.

From the documentation[1]:
```
The classifier distinguishes artifacts that were built from the same POM
but differ in content. It is some optional and arbitrary string that -
if present - is appended to the artifact name just after the version number.
As a motivation for this element, consider for example a project that
offers an artifact targeting JRE 1.5 but at the same time also an
artifact that still supports JRE 1.4. The first artifact could be
equipped with the classifier jdk15 and the second one with jdk14 such
that clients can choose which one to use.

Another common use case for classifiers is to attach secondary artifacts
to the project's main artifact. If you browse the Maven central
repository, you will notice that the classifiers sources and javadoc are
used to deploy the project source code and API docs along with the
packaged class files.
```
So an android package could simply be namind by using:

g: com.google.guava
a: guava
v: 27.1
classifier: jre

etc.
classifier: android

Unfortunately they had decided to put this into the version which causes
the issues. This in result means you can not select the version correctly.


[1]: https://maven.apache.org/pom.html


2) i'm trying to use the version range "[4.7.0,5) "for
io.cucumber:cucumber-core. So i'm expecting it to use 4.8.0, not
5.0.0-RC1 which is being picked up, i.e. mvn dependency:tree -Dverbose
-Dincludes=io.cucumber

https://search.maven.org/artifact/io.cucumber/cucumber-core

what do i need to change "[4.7.0,5)" to do it excludes anything starting 5?

So next checking for version comparison:

This can be checked via command line: (from the Apache Maven installation):

$ java -jar maven-artifact-3.6.2.jar 4.7.0 5
Display parameters as parsed by Maven (in canonical form) and comparison
result:
1. 4.7.0 == 4.7
   4.7.0 < 5
2. 5 == 5

This will show the obvious as you already know. Now let us check
something different:

lib$ java -jar maven-artifact-3.6.2.jar  5.0.0-alpha 5.0.0
Display parameters as parsed by Maven (in canonical form) and comparison
result:
1. 5.0.0-alpha == 5-alpha
   5.0.0-alpha < 5.0.0
2. 5.0.0 == 5

So based on that your version range: [4,5) will include everything which
starts with "5.0.0", "5.0", or "5" this will also include "-RC??",
"-alpha" and "-SNAPSHOT" because they are less than "5", "5.0" or
"5.0.0" etc.

Furthermore I would say "5" < "5-SNAPSHOT" is from a Maven point of view
is very intuitve cause the "SNAPSHOT" is on the timeline before
releasing final release "5". (This is also true for "5.0.0" <
"5.0.0-SNAPSHOT").

To prevent having "RC"'s etc. in your range the only way is to use
"[4,4.9999999.99999)" (Yes it looks strange.) for given example
cucumber-core...


Also see the discussion on the users list:
https://lists.apache.org/thread.html/888730bd2479a9ae247e12b1f7ae6a85285feb395bdfe99c2e435a46@<users.maven.apache.org>

Unfortunately I agree that from a user point of view this should be done
better.

This could be changed for Maven 4.X but never for Maven 3.X.

In the end my opinion (and experience) is simply not to use version
ranges at all cause that could break your build without knowing why
..(I've seen that several times already)...

Kind regards
Karl Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to