From 76ffd41c97d7e6c7bd5219b9e29ee9e22b4a3c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C4=8C=C3=A1bera?= Date: Mon, 22 Jan 2024 22:45:23 +0100 Subject: [PATCH] [java] Support groovy installations (#779) * [java] Support groovy installations Fix java test failing with non existent 19 version of `open` distro * fix: Typo * feat: Implement code review comments --------- Co-authored-by: Samruddhi Khandale --- src/java/devcontainer-feature.json | 23 ++++++++++++++++--- src/java/install.sh | 7 ++++++ ...ll_ant_and_gradle_and_maven_and_groovy.sh} | 6 +++++ ...d_gradle_and_maven_and_groovy_for_user.sh} | 6 +++++ ...maven_and_groovy_with_specific_version.sh} | 2 ++ test/java/install_from_non_default_distro.sh | 2 +- test/java/scenarios.json | 20 +++++++++------- 7 files changed, 54 insertions(+), 12 deletions(-) rename test/java/{install_ant_and_gradle_and_maven.sh => install_ant_and_gradle_and_maven_and_groovy.sh} (84%) rename test/java/{install_ant_and_gradle_and_maven_for_user.sh => install_ant_and_gradle_and_maven_and_groovy_for_user.sh} (84%) rename test/java/{install_ant_and_gradle_and_maven_with_specific_version.sh => install_ant_and_gradle_and_maven_and_groovy_with_specific_version.sh} (92%) diff --git a/src/java/devcontainer-feature.json b/src/java/devcontainer-feature.json index d4aede873..64a4ca932 100644 --- a/src/java/devcontainer-feature.json +++ b/src/java/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "java", - "version": "1.2.2", + "version": "1.3.0", "name": "Java (via SDKMAN!)", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/java", "description": "Installs Java, SDKMAN! (if not installed), and needed dependencies.", @@ -23,7 +23,8 @@ "ms", "open", "oracle", - "tem" + "tem", + "amzn" ], "default": "ms", "description": "Select or enter a JDK distribution" @@ -74,6 +75,22 @@ ], "default": "latest", "description": "Select or enter an Ant version" + }, + "installGroovy": { + "type": "boolean", + "default": false, + "description": "Install Groovy, powerful, optionally typed and dynamic language with static-typing and static compilation capabilities" + }, + "groovyVersion": { + "type": "string", + "proposals": [ + "latest", + "2.5.22", + "3.0.19", + "4.0.16" + ], + "default": "latest", + "description": "Select or enter a Groovy version" } }, "customizations": { @@ -92,6 +109,6 @@ "PATH": "/usr/local/sdkman/bin:/usr/local/sdkman/candidates/java/current/bin:/usr/local/sdkman/candidates/gradle/current/bin:/usr/local/sdkman/candidates/maven/current/bin:/usr/local/sdkman/candidates/ant/current/bin:${PATH}" }, "installsAfter": [ - "ghcr.io/devcontainers/features/common-utils" + "ghcr.io/devcontainers/features/common-utils" ] } diff --git a/src/java/install.sh b/src/java/install.sh index 2decc31b5..16bbb1c66 100644 --- a/src/java/install.sh +++ b/src/java/install.sh @@ -16,6 +16,8 @@ INSTALL_MAVEN="${INSTALLMAVEN:-"false"}" MAVEN_VERSION="${MAVENVERSION:-"latest"}" INSTALL_ANT="${INSTALLANT:-"false"}" ANT_VERSION="${ANTVERSION:-"latest"}" +INSTALL_GROOVY="${INSTALLGROOVY:-"false"}" +GROOVY_VERSION="${GROOVYVERSION:-"latest"}" JDK_DISTRO="${JDKDISTRO}" export SDKMAN_DIR="${SDKMAN_DIR:-"/usr/local/sdkman"}" @@ -190,6 +192,11 @@ if [[ "${INSTALL_MAVEN}" = "true" ]] && ! mvn --version > /dev/null; then sdk_install maven ${MAVEN_VERSION} fi +# Install Groovy +if [[ "${INSTALL_GROOVY}" = "true" ]] && ! groovy --version > /dev/null; then + sdk_install groovy "${GROOVY_VERSION}" +fi + # Clean up rm -rf /var/lib/apt/lists/* diff --git a/test/java/install_ant_and_gradle_and_maven.sh b/test/java/install_ant_and_gradle_and_maven_and_groovy.sh similarity index 84% rename from test/java/install_ant_and_gradle_and_maven.sh rename to test/java/install_ant_and_gradle_and_maven_and_groovy.sh index 599f8d9d5..e171f5be5 100644 --- a/test/java/install_ant_and_gradle_and_maven.sh +++ b/test/java/install_ant_and_gradle_and_maven_and_groovy.sh @@ -24,5 +24,11 @@ check "maven" mvn --version cd /tmp && mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false check "m2 exists" grep ".m2" <(ls -la /root) +check "groovy" groovy --version +cat << EOF > /tmp/test.groovy +println("verify") +EOF +check "groovy works" test "$(groovy /tmp/test.groovy)" = "verify" + # Report result reportResults diff --git a/test/java/install_ant_and_gradle_and_maven_for_user.sh b/test/java/install_ant_and_gradle_and_maven_and_groovy_for_user.sh similarity index 84% rename from test/java/install_ant_and_gradle_and_maven_for_user.sh rename to test/java/install_ant_and_gradle_and_maven_and_groovy_for_user.sh index 4e8b43134..8d9f293e9 100644 --- a/test/java/install_ant_and_gradle_and_maven_for_user.sh +++ b/test/java/install_ant_and_gradle_and_maven_and_groovy_for_user.sh @@ -24,5 +24,11 @@ check "maven" mvn --version cd /tmp && mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false check "m2 exists" grep ".m2" <(ls -la /home/vscode) +check "groovy" groovy --version +cat << EOF > /tmp/test.groovy +println("verify") +EOF +check "groovy works" test "$(groovy /tmp/test.groovy)" = "verify" + # Report result reportResults diff --git a/test/java/install_ant_and_gradle_and_maven_with_specific_version.sh b/test/java/install_ant_and_gradle_and_maven_and_groovy_with_specific_version.sh similarity index 92% rename from test/java/install_ant_and_gradle_and_maven_with_specific_version.sh rename to test/java/install_ant_and_gradle_and_maven_and_groovy_with_specific_version.sh index 7727f51b6..54e13e0cf 100644 --- a/test/java/install_ant_and_gradle_and_maven_with_specific_version.sh +++ b/test/java/install_ant_and_gradle_and_maven_and_groovy_with_specific_version.sh @@ -24,5 +24,7 @@ check "maven version" grep "Apache Maven 3.6.3" <(mvn --version) cd /tmp && mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false check "m2 exists" grep ".m2" <(ls -la /root) +check "groovy version" grep "Groovy Version: 2.5.22" <(groovy --version) + # Report result reportResults diff --git a/test/java/install_from_non_default_distro.sh b/test/java/install_from_non_default_distro.sh index 021a72a21..3ab648cab 100644 --- a/test/java/install_from_non_default_distro.sh +++ b/test/java/install_from_non_default_distro.sh @@ -5,7 +5,7 @@ set -e # Optional: Import test library source dev-container-features-test-lib -check "java version openjdk 19 installed" grep "openjdk 19." <(java --version) +check "java version openjdk 21 installed" grep "openjdk 21." <(java --version) # Report result reportResults diff --git a/test/java/scenarios.json b/test/java/scenarios.json index 5d7e684ba..dac9850f2 100644 --- a/test/java/scenarios.json +++ b/test/java/scenarios.json @@ -3,7 +3,7 @@ "image": "ubuntu:focal", "features": { "java": { - "version": "19", + "version": "21", "jdkDistro": "open" } } @@ -17,7 +17,7 @@ } } }, - "install_ant_and_gradle_and_maven_for_user": { + "install_ant_and_gradle_and_maven_and_groovy_for_user": { "image": "ubuntu:focal", "remoteUser": "vscode", "features": { @@ -28,22 +28,24 @@ "version": "latest", "installAnt": true, "installGradle": true, - "installMaven": true + "installMaven": true, + "installGroovy": true } } }, - "install_ant_and_gradle_and_maven": { + "install_ant_and_gradle_and_maven_and_groovy": { "image": "ubuntu:focal", "features": { "java": { "version": "latest", "installAnt": true, "installGradle": true, - "installMaven": true + "installMaven": true, + "installGroovy": true } } }, - "install_ant_and_gradle_and_maven_with_specific_version": { + "install_ant_and_gradle_and_maven_and_groovy_with_specific_version": { "image": "ubuntu:focal", "features": { "java": { @@ -53,13 +55,15 @@ "installGradle": "true", "gradleVersion": "6.8.3", "installMaven": "true", - "mavenVersion": "3.6.3" + "mavenVersion": "3.6.3", + "installGroovy": "true", + "groovyVersion": "2.5.22" } } }, "install_non_conventional_version": { "image": "ubuntu:focal", - "features":{ + "features": { "java": { "version": "21", "jdkDistro": "graalce"