Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/java/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "java",
"version": "1.6.2",
"version": "1.6.3",
"name": "Java (via SDKMAN!)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/java",
"description": "Installs Java, SDKMAN! (if not installed), and needed dependencies.",
Expand All @@ -10,6 +10,7 @@
"proposals": [
"latest",
"none",
"21",
"17",
"11",
"8"
Expand Down
11 changes: 10 additions & 1 deletion src/java/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,20 @@ find_version_list() {
major_version=$(echo "$java_ver" | cut -d '.' -f 1)
fi

# Remove the hardcoded fallback as this fails for new jdk latest version released ex: 24
# Related Issue: https://github.com/devcontainers/features/issues/1308
if [ "${JDK_DISTRO}" = "ms" ]; then
if [ "${major_version}" = "8" ] || [ "${major_version}" = "18" ] || [ "${major_version}" = "22" ] || [ "${major_version}" = "23" ]; then
# Check if the requested version is available in the 'ms' distribution
echo "Check if OpenJDK is available for version ${major_version} for ${JDK_DISTRO} Distro"
available_versions=$(su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk list ${install_type} | grep ${JDK_DISTRO} | grep -oE '[0-9]+(\.[0-9]+(\.[0-9]+)?)?' | sort -u")
if echo "${available_versions}" | grep -q "^${major_version}"; then
echo "JDK version ${major_version} is available in ${JDK_DISTRO}..."
else
echo "JDK version ${major_version} not available in ${JDK_DISTRO}.... Switching to (tem)."
JDK_DISTRO="tem"
fi
fi
echo "JDK_DISTRO: ${JDK_DISTRO}"
if [ "${install_type}" != "java" ]; then
regex="${prefix}\\K[0-9]+\\.?[0-9]*\\.?[0-9]*${suffix}"
else
Expand Down
2 changes: 1 addition & 1 deletion test/java/install_latest_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ echo 'public class HelloWorld { public static void main(String[] args) { System.
javac HelloWorld.java

check "hello world" /bin/bash -c "java HelloWorld | grep "Hello, World!""
check "java version latest installed" grep "23" <(java --version)
check "java version latest installed" grep "24" <(java --version)

# Report result
reportResults