Skip to content
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

[java] Support groovy installations #779

Merged
merged 5 commits into from
Jan 22, 2024
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
23 changes: 20 additions & 3 deletions src/java/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand All @@ -23,7 +23,8 @@
"ms",
"open",
"oracle",
"tem"
"tem",
"amzn"
],
"default": "ms",
"description": "Select or enter a JDK distribution"
Expand Down Expand Up @@ -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": {
Expand All @@ -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"
]
}
7 changes: 7 additions & 0 deletions src/java/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}"
Expand Down Expand Up @@ -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/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 19 installed" grep "openjdk 19." <(java --version)
check "java version openjdk 21 installed" grep "openjdk 21." <(java --version)

# Report result
reportResults
20 changes: 12 additions & 8 deletions test/java/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"image": "ubuntu:focal",
"features": {
"java": {
"version": "19",
samruddhikhandale marked this conversation as resolved.
Show resolved Hide resolved
"version": "21",
"jdkDistro": "open"
}
}
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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"
Expand Down