Since I was unable to find a way to explicitly define the desired default version for Java, I've patched Mk/bsd.default-versions.mk and Mk/bsd.java.mk to enable use of: DEFAULT_VERSIONS+= java=11 in the make.conf. Jonathan Chen has hinted to use: JAVA_PREFERRED_PORTS= JAVA_PORT_NATIVE_OPENJDK_JDK_11 Which I think is too long and not with the DEFAULT_VERSIONS standard like other languages. I've spot check (via 'make java-debug') for some of the ports and it works. It ensures the strictness of the port while attempting to meet the user's needs. ========================================================================== databases/jdbc-oracle11g # User specified parameters: JAVA_VERSION= 1.7 1.8 (7 8) JAVA_OS= (native linux) JAVA_VENDOR= (openjdk oracle) JAVA_BUILD= JAVA_RUN= jre JAVA_EXTRACT= JAVA_DEFAULT= 11 # JDK port dependency selection process: _JAVA_PORTS_POSSIBLE= JAVA_PORT_NATIVE_OPENJDK_JDK_8 JAVA_PORT_NATIVE_OPENJDK_JDK_7 JAVA_PORT_LINUX_ORACLE_JDK_8 _JAVA_PORTS_INSTALLED= _JAVA_PORTS_INSTALLED_POSSIBLE= _JAVA_PORT= JAVA_PORT_NATIVE_OPENJDK_JDK_8 _JAVA_PORT_INFO= PORT=java/openjdk8 HOME=/usr/local/openjdk8 VERSION=8 OS=native VENDOR=openjdk _JAVA_VERSION_MIN= 8 _CAN_USE_NEWER= # Selected JDK port: JAVA_PORT= java/openjdk8 JAVA_HOME= /usr/local/openjdk8 JAVA_PORT_VERSION= 8 JAVA_PORT_OS= native (Native) JAVA_PORT_VENDOR= openjdk (OpenJDK BSD Porting Team) # Additional variables: JAVAC= JAVA_CLASSES= /usr/local/openjdk8/jre/lib/rt.jar ========================================================================== www/tomcat9 # User specified parameters: JAVA_VERSION= 1.8+ (8 11 12 13) JAVA_OS= (native linux) JAVA_VENDOR= (openjdk oracle) JAVA_BUILD= JAVA_RUN= jre JAVA_EXTRACT= JAVA_DEFAULT= 11 # JDK port dependency selection process: _JAVA_PORTS_POSSIBLE= JAVA_PORT_NATIVE_OPENJDK_JDK_8 JAVA_PORT_NATIVE_OPENJDK_JDK_11 JAVA_PORT_NATIVE_OPENJDK_JDK_12 JAVA_PORT_NATIVE_OPENJDK_JDK_13 JAVA_PORT_LINUX_ORACLE_JDK_8 _JAVA_PORTS_INSTALLED= _JAVA_PORTS_INSTALLED_POSSIBLE= _JAVA_PORT= JAVA_PORT_NATIVE_OPENJDK_JDK_11 _JAVA_PORT_INFO= PORT=java/openjdk11 HOME=/usr/local/openjdk11 VERSION=11 OS=native VENDOR=openjdk _JAVA_VERSION_MIN= 8 _CAN_USE_NEWER= + # Selected JDK port: JAVA_PORT= java/openjdk11 JAVA_HOME= /usr/local/openjdk11 JAVA_PORT_VERSION= 11 JAVA_PORT_OS= native (Native) JAVA_PORT_VENDOR= openjdk (OpenJDK BSD Porting Team) # Additional variables: JAVAC= JAVA_CLASSES= /usr/local/openjdk11/jre/lib/rt.jar ========================================================================== devel/smc # User specified parameters: JAVA_VERSION= (7 8 11 12 13) JAVA_OS= (native linux) JAVA_VENDOR= (openjdk oracle) JAVA_BUILD= JAVA_RUN= jre JAVA_EXTRACT= JAVA_DEFAULT= 11 # JDK port dependency selection process: _JAVA_PORTS_POSSIBLE= JAVA_PORT_NATIVE_OPENJDK_JDK_8 JAVA_PORT_NATIVE_OPENJDK_JDK_11 JAVA_PORT_NATIVE_OPENJDK_JDK_12 JAVA_PORT_NATIVE_OPENJDK_JDK_13 JAVA_PORT_NATIVE_OPENJDK_JDK_7 JAVA_PORT_LINUX_ORACLE_JDK_8 _JAVA_PORTS_INSTALLED= _JAVA_PORTS_INSTALLED_POSSIBLE= _JAVA_PORT= JAVA_PORT_NATIVE_OPENJDK_JDK_11 _JAVA_PORT_INFO= PORT=java/openjdk11 HOME=/usr/local/openjdk11 VERSION=11 OS=native VENDOR=openjdk _JAVA_VERSION_MIN= _CAN_USE_NEWER= # Selected JDK port: JAVA_PORT= java/openjdk11 JAVA_HOME= /usr/local/openjdk11 JAVA_PORT_VERSION= 11 JAVA_PORT_OS= native (Native) JAVA_PORT_VENDOR= openjdk (OpenJDK BSD Porting Team) # Additional variables: JAVAC= JAVA_CLASSES= /usr/local/openjdk11/jre/lib/rt.jar
Created attachment 212564 [details] Patch for Mk/bsd.default-versions.mk and Mk/bsd.java.mk
Created attachment 212565 [details] Patch for Mk/bsd.default-versions.mk and Mk/bsd.java.mk
Created attachment 212566 [details] Patch for Mk/bsd.default-versions.mk and Mk/bsd.java.mk Fix for another variation 8+: devel/jna # User specified parameters: JAVA_VERSION= 8+ (8 11 12 13) JAVA_OS= (native linux) JAVA_VENDOR= (openjdk oracle) JAVA_BUILD= jdk JAVA_RUN= jre JAVA_EXTRACT= JAVA_DEFAULT= 11 # JDK port dependency selection process: _JAVA_PORTS_POSSIBLE= JAVA_PORT_NATIVE_OPENJDK_JDK_8 JAVA_PORT_NATIVE_OPENJDK_JDK_11 JAVA_PORT_NATIVE_OPENJDK_JDK_12 JAVA_PORT_NATIVE_OPENJDK_JDK_13 JAVA_PORT_LINUX_ORACLE_JDK_8 _JAVA_PORTS_INSTALLED= _JAVA_PORTS_INSTALLED_POSSIBLE= _JAVA_PORT= JAVA_PORT_NATIVE_OPENJDK_JDK_11 _JAVA_PORT_INFO= PORT=java/openjdk11 HOME=/usr/local/openjdk11 VERSION=11 OS=native VENDOR=openjdk _JAVA_VERSION_MIN= 8 _CAN_USE_NEWER= + # Selected JDK port: JAVA_PORT= java/openjdk11 JAVA_HOME= /usr/local/openjdk11 JAVA_PORT_VERSION= 11 JAVA_PORT_OS= native (Native) JAVA_PORT_VENDOR= openjdk (OpenJDK BSD Porting Team) # Additional variables: JAVAC= /usr/local/openjdk11/bin/javac JAVA_CLASSES= /usr/local/openjdk11/jre/lib/rt.jar
Thanks for the patch. I wonder if it might not be simpler though to just change how bsd.java.mk sets up _JAVA_PORTS_ALL and add in JAVA_PORT_NATIVE_OPENJDK_JDK_${JAVA_DEFAULT} in between ${JAVA_PREFERRED_PORTS} and ${__JAVA_PORTS_ALL}. Wouldn't that essentially achieve what you want?
(In reply to Greg Lewis from comment #4) Hi Greg, Yes, it would. It works like my patch. Thank you.
Created attachment 212666 [details] Patch for Mk/bsd.default-versions.mk and Mk/bsd.java.mk Better patch based on Greg's suggestion.
Sorry for the delay, my plan is to commit this tomorrow morning
A commit references this bug: Author: glewis Date: Sat Apr 11 17:10:04 UTC 2020 New revision: 531437 URL: https://svnweb.freebsd.org/changeset/ports/531437 Log: Allow users to specify a default Java version in the standard way PR: 244942 Submitted by: Tommy P <tommyhp2@gmail.com> Changes: head/Mk/bsd.default-versions.mk head/Mk/bsd.java.mk
Thanks for this!