Skip to content

Commit

Permalink
[java] fix version regex to support graalce jdk 21 (#701)
Browse files Browse the repository at this point in the history
* [java] fixed feature test scenario check

* [java] support for non conentional version

* Update src/java/install.sh to not include whitespaces

Co-authored-by: Samruddhi Khandale <[email protected]>

* bumped patch version

---------

Co-authored-by: Samruddhi Khandale <[email protected]>
  • Loading branch information
prulloac and samruddhikhandale authored Sep 27, 2023
1 parent 3a22c41 commit 9852ca8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 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.2.1",
"version": "1.2.2",
"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 Down
4 changes: 2 additions & 2 deletions src/java/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ sdk_install() {
elif echo "${requested_version}" | grep -oE "${full_version_check}" > /dev/null 2>&1; then
echo "${requested_version}"
else
local regex="${prefix}\\K[0-9]+\\.[0-9]+\\.[0-9]+${suffix}"
local regex="${prefix}\\K[0-9]+\\.?[0-9]*\\.?[0-9]*${suffix}"
local version_list=$(su ${USERNAME} -c ". \${SDKMAN_DIR}/bin/sdkman-init.sh && sdk list ${install_type} 2>&1 | grep -oP \"${regex}\" | tr -d ' ' | sort -rV")
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ]; then
requested_version="$(echo "${version_list}" | head -n 1)"
else
set +e
requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
requested_version="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|-|$)")"
set -e
fi
if [ -z "${requested_version}" ] || ! echo "${version_list}" | grep "^${requested_version//./\\.}$" > /dev/null 2>&1; then
Expand Down
2 changes: 1 addition & 1 deletion test/java/install_from_non_default_distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
# Optional: Import test library
source dev-container-features-test-lib

check "java version openjdk 11 installed" grep "openjdk 11." <(java --version)
check "java version openjdk 19 installed" grep "openjdk 19." <(java --version)

# Report result
reportResults
11 changes: 11 additions & 0 deletions test/java/install_non_conventional_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

check "java version openjdk 21 installed" grep "openjdk 21." <(java --version)

# Report result
reportResults
9 changes: 9 additions & 0 deletions test/java/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,14 @@
"mavenVersion": "3.6.3"
}
}
},
"install_non_conventional_version": {
"image": "ubuntu:focal",
"features":{
"java": {
"version": "21",
"jdkDistro": "graalce"
}
}
}
}

0 comments on commit 9852ca8

Please sign in to comment.