aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/java/devcontainer-feature.json14
-rw-r--r--src/java/install.sh14
-rw-r--r--test-scenarios/install_gradle_and_maven.sh12
-rw-r--r--test-scenarios/scenarios.json10
4 files changed, 49 insertions, 1 deletions
diff --git a/src/java/devcontainer-feature.json b/src/java/devcontainer-feature.json
index 11566ae..0c2a968 100644
--- a/src/java/devcontainer-feature.json
+++ b/src/java/devcontainer-feature.json
@@ -15,6 +15,16 @@
],
"default": "lts",
"description": "Select or enter a Java version to install"
+ },
+ "install_gradle": {
+ "type": "boolean",
+ "default": false,
+ "description": "Install Gradle, a build automation tool for multi-language software development"
+ },
+ "install_maven": {
+ "type": "boolean",
+ "default": false,
+ "description": "Install Maven, a management tool for Java"
}
},
"buildArg": "_VSC_INSTALL_JAVA",
@@ -23,7 +33,9 @@
],
"containerEnv": {
"SDKMAN_DIR": "/usr/local/sdkman",
- "PATH": "${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/java/current/bin:${PATH}"
+ "GRADLE_USER_HOME": "${HOME}/.gradle",
+ "M2": "${HOME}/.m2",
+ "PATH": "${SDKMAN_DIR}/bin:${SDKMAN_DIR}/candidates/java/current/bin:${SDKMAN_DIR}/candidates/gradle/current/bin:${SDKMAN_DIR}/candidates/maven/current/bin:${PATH}"
},
"settings": {
"java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current"
diff --git a/src/java/install.sh b/src/java/install.sh
index 64646fa..411fffb 100644
--- a/src/java/install.sh
+++ b/src/java/install.sh
@@ -10,6 +10,8 @@
# Syntax: ./java-debian.sh [JDK version] [SDKMAN_DIR] [non-root user] [Add to rc files flag]
JAVA_VERSION=${VERSION:-"lts"}
+INSTALL_GRADLE=${INSTALL_GRADLE:-"false"}
+INSTALL_MAVEN=${INSTALL_MAVEN:-"false"}
export SDKMAN_DIR=${SDKMAN_DIR:-"/usr/local/sdkman"}
USERNAME=${USERNAME:-"automatic"}
@@ -167,4 +169,16 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk default java ${JAVA_VERSION}"
fi
+# Install Gradle
+if [[ "${INSTALL_GRADLE}" = "true" ]] && ! gradle --version > /dev/null; then
+ sdk_install gradle latest
+ updaterc '[ -z "${GRADLE_USER_HOME}" ] && export GRADLE_USER_HOME=${HOME}/.gradle'
+fi
+
+# Install Maven
+if [[ "${INSTALL_MAVEN}" = "true" ]] && ! mvn --version > /dev/null; then
+ sdk_install maven latest
+ updaterc '[ -z "$M2" ] && export M2=$HOME/.m2'
+fi
+
echo "Done!"
diff --git a/test-scenarios/install_gradle_and_maven.sh b/test-scenarios/install_gradle_and_maven.sh
new file mode 100644
index 0000000..4324667
--- /dev/null
+++ b/test-scenarios/install_gradle_and_maven.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+# Optional: Import test library
+source dev-container-features-test-lib
+
+check "gradle" gradle --version
+check "maven" mvn --version
+
+# Report result
+reportResults
diff --git a/test-scenarios/scenarios.json b/test-scenarios/scenarios.json
index 887c219..20d802c 100644
--- a/test-scenarios/scenarios.json
+++ b/test-scenarios/scenarios.json
@@ -1,4 +1,14 @@
{
+ "install_gradle_and_maven": {
+ "image": "ubuntu:focal",
+ "features": {
+ "java": {
+ "version": "17",
+ "install_gradle": true,
+ "install_maven": true
+ }
+ }
+ },
"install_additional_php": {
"image": "ubuntu:focal",
"features": {