Created attachment 268380 [details] Patch Currently, USES=java picks openjdk version inconsistently to what we do for other ecosystems, preferring ancient versions and ignoring value set in bsd.default-versions.mk. Apart from using outdated openjdk, this behavior tends to bring unnecessary numerous openjdk versions to the system (when many java ports with different JAVA_VERSION settings) and leaves maintainers wondering about which JAVA_VERSION to use. This patch adds support for JAVA_VERSION=default (which translates the the version from bsd.default-version.mk or later) and JAVA_VERSION=latest (which translates to the latest available version). This change is non-breaking and does not affect existing ports, but allows ports to gradually switch to JAVA_VERSION=default, which will reduce the assortment of required openjdk versions and bring in newer one. In the future I hope that we will switch to it by default.
Check this bug #289858. IMHO, something like priority would be better.
Also default java just updated to 21 in bug #272855.
I like the idea of your change. The JAVA_VERSION=latest seems a nice new feature to me. What I don’t understand, how is JAVA_VERSION=default different from not setting JAVA_VERSION at all? And do you have an example of “preferring ancient versions and ignoring value set in bsd.default-versions.mk”? I saw a port with JAVA_VERSION=17+ correctly choosing openjdk21 now 21 is the default. https://www.freshports.org/astro/traccar/
I'm generally against any logic which relies on which ports are installed - this makes behavior inconsistent between different port install orders and between ports and packages, and is still inconsistent to how we handle other ecosystems (and that we do by pinning exact version of e.g. python). In fact, while my `JAVA_VERSION=default` equals to `JAVA_VERSION=${JAVA_DEFAULT}+` to stay closer to status quo where `X+` are used in most ports, IMO it would make more sense to pin specific version (`JAVA_VERSION=${JAVA_DEFAULT}`) as long as `JAVA_DEFAULT` is being reliably kept up to date. That said, it doesn't look that these patches are conflicting - my patch is about choosing a version range (effecively limiting it from below), and a patch from 289858 is about picking a version in that range.
(In reply to Ronald Klop from comment #3) > What I don’t understand, how is JAVA_VERSION=default different from not setting > JAVA_VERSION at all? Not setting JAVA_VERSION at all currently equals to 8+, which picks openjdk8 if no newer one is installed.
> And do you have an example of “preferring ancient versions and ignoring value set in bsd.default-versions.mk”? I saw a port with JAVA_VERSION=17+ correctly choosing openjdk21 now 21 is the default. Oh, that seem to have changed just a moment ago. > Also default java just updated to 21 in bug #272855. Not sure if either patch is needed any more.