devonfw / ide

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

Version-prefix not working as expected #1112

Closed hohwille closed 1 year ago

hohwille commented 1 year ago

I configured JAVA_VERSION=17.*. According to #893 my expectation was that this would work. However it did not:

******** ATTENTION ********
Could not resolve version prefix 17.* : no matching version found in /d/projects/test/mirrors/java/available-versions
We are sorry for the inconvenience. Please check the above errors, resolve them and try again.
Command 'java setup silent' failed with exit code 255

It only works with JAVA_VERSION=17*.

hohwille commented 1 year ago

Indeed I implemented this so this can not work: https://github.com/devonfw/ide/blob/59785e4e5dcf8e47ec6cd59b9e6e40f8ccc3e829/scripts/src/main/resources/scripts/functions#L1284

hohwille commented 1 year ago

IMHO we simply need to check if the version_prefix (excluding the asterisk) ends with a digit (0-9). If yes, the old behavior shall still apply but otherwise the [^0-9] part from the grep regex shall be omitted.

hohwille commented 1 year ago

It seems that . is matched in regex syntax by grep command so we would need to escape this accordingly (replace . with \. in version_prefix via ${version_prefix/./\\.}...

hohwille commented 1 year ago

Examples:

  1. TOOL_VERSION=1* --> matches version 1, 1.0, 1.1, 1.1.2-beta3, etc. but not 10, 11.1 or so. --> we add [^0-9]
  2. TOOL_VERSION=1.* --> matches any version starting with 1. so 1.0, 1.1, 1.1.2-beta3, etc. but not 1, 10, 11.1 or so.