Skip to content

[java] - Changes to install latest maven stable version with sdkman #1384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
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.6.3",
"version": "1.6.4",
"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
14 changes: 13 additions & 1 deletion src/java/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
# Syntax: ./java-debian.sh [JDK version] [SDKMAN_DIR] [non-root user] [Add to rc files flag]

set -x

JAVA_VERSION="${VERSION:-"latest"}"
INSTALL_GRADLE="${INSTALLGRADLE:-"false"}"
GRADLE_VERSION="${GRADLEVERSION:-"latest"}"
Expand Down Expand Up @@ -340,7 +342,17 @@ fi

# Install Maven
if [[ "${INSTALL_MAVEN}" = "true" ]] && ! mvn --version > /dev/null 2>&1; then
sdk_install maven ${MAVEN_VERSION}
MAVEN_VERSION_TO_INSTALL="${MAVEN_VERSION}"
if [ "${MAVEN_VERSION}" = "latest" ]; then
# Get the latest stable Maven version from sdk list
MAVEN_VERSION_TO_INSTALL=$(
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && \
sdk list maven | grep -E '^[[:space:]]*[0-9]+(\.[0-9]+)*[[:space:]]' | grep -v -- '-' | head -n 1 | awk '{print \$1}'"
)
echo "Resolved latest stable Maven version: ${MAVEN_VERSION_TO_INSTALL}"
fi

sdk_install maven "${MAVEN_VERSION_TO_INSTALL}"
fi

# Install Groovy
Expand Down