Unverified Commit 76ffd41c authored by Jakub Čábera's avatar Jakub Čábera Committed by GitHub

[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: 's avatarSamruddhi Khandale <skhandale@microsoft.com>
parent 65fb90b7
{
"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"
]
}
......@@ -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/*
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment