devonfw / ide

Tool to automate setup and update of development environment (esp. for Java projects).
Apache License 2.0
33 stars 102 forks source link

Detection of latest Java version is buggy #1367

Closed hohwille closed 5 months ago

hohwille commented 8 months ago
$ devon java version set 21
21.0.1_12  21_35

$ devon java version set 21*
JAVA_VERSION=21* has been set in /d/projects/mmm/settings/devon.properties
To install that version call the following command:
devon java setup

$ devon java setup
Updating java from version 17.0.8_7 to version 21_35...

Vising https://adoptium.net/ confirms that this is a bug and 21.0.1_12 is newer than 21_35. Indeed an edge-case from the version compare function but with Java a very relevant one. The problem is that semantics like . vs. _ are actually undefined. However, if both versions have an underscore (_) it seems kind of natural to first compare the prefix part before the underscore and only if equal then compare the suffix part so:

A remaining question would be the comparison of 21.0.1.12 with 21_35 and IMHO there can not be a clear answer as it may depend on the project/product creating these versions.

I guess for Java the suffix starting with the _ is some kind of build number.

hohwille commented 7 months ago

Suggestion: Follow TDD with Red/Green pattern and first extend test-version-compare by adding the example from this story. Then this test should fail. After that try to implement the story and rerun the test until it is green.