Unverified Commit d78a1534 authored by Tobias Gesellchen's avatar Tobias Gesellchen Committed by GitHub

Java: add Apache Ant (#409)

* Java: add Apache Ant

* Update src/java/devcontainer-feature.json
Co-authored-by: 's avatarSamruddhi Khandale <skhandale@microsoft.com>

* revert the changes in README.md

* Add tests for Java/Ant

* Fix Java feature version
Co-authored-by: 's avatarSamruddhi Khandale <skhandale@microsoft.com>
parent f7314671
{ {
"id": "java", "id": "java",
"version": "1.1.1", "version": "1.2.0",
"name": "Java (via SDKMAN!)", "name": "Java (via SDKMAN!)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/java", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/java",
"description": "Installs Java, SDKMAN! (if not installed), and needed dependencies.", "description": "Installs Java, SDKMAN! (if not installed), and needed dependencies.",
...@@ -59,6 +59,21 @@ ...@@ -59,6 +59,21 @@
], ],
"default": "latest", "default": "latest",
"description": "Select or enter a Maven version" "description": "Select or enter a Maven version"
},
"installAnt": {
"type": "boolean",
"default": false,
"description": "Install Ant, a software tool for automating software build processes"
},
"antVersion": {
"type": "string",
"proposals": [
"latest",
"1.10.12",
"1.9.15"
],
"default": "latest",
"description": "Select or enter an Ant version"
} }
}, },
"customizations": { "customizations": {
...@@ -74,7 +89,7 @@ ...@@ -74,7 +89,7 @@
"containerEnv": { "containerEnv": {
"SDKMAN_DIR": "/usr/local/sdkman", "SDKMAN_DIR": "/usr/local/sdkman",
"JAVA_HOME": "/usr/local/sdkman/candidates/java/current", "JAVA_HOME": "/usr/local/sdkman/candidates/java/current",
"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:${PATH}" "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": [ "installsAfter": [
"ghcr.io/devcontainers/features/common-utils" "ghcr.io/devcontainers/features/common-utils"
......
...@@ -14,6 +14,8 @@ INSTALL_GRADLE="${INSTALLGRADLE:-"false"}" ...@@ -14,6 +14,8 @@ INSTALL_GRADLE="${INSTALLGRADLE:-"false"}"
GRADLE_VERSION="${GRADLEVERSION:-"latest"}" GRADLE_VERSION="${GRADLEVERSION:-"latest"}"
INSTALL_MAVEN="${INSTALLMAVEN:-"false"}" INSTALL_MAVEN="${INSTALLMAVEN:-"false"}"
MAVEN_VERSION="${MAVENVERSION:-"latest"}" MAVEN_VERSION="${MAVENVERSION:-"latest"}"
INSTALL_ANT="${INSTALLANT:-"false"}"
ANT_VERSION="${ANTVERSION:-"latest"}"
JDK_DISTRO="${JDKDISTRO}" JDK_DISTRO="${JDKDISTRO}"
export SDKMAN_DIR="${SDKMAN_DIR:-"/usr/local/sdkman"}" export SDKMAN_DIR="${SDKMAN_DIR:-"/usr/local/sdkman"}"
...@@ -173,6 +175,11 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then ...@@ -173,6 +175,11 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk default java ${JAVA_VERSION}" su ${USERNAME} -c ". ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk default java ${JAVA_VERSION}"
fi fi
# Install Ant
if [[ "${INSTALL_ANT}" = "true" ]] && ! ant -version > /dev/null; then
sdk_install ant ${ANT_VERSION}
fi
# Install Gradle # Install Gradle
if [[ "${INSTALL_GRADLE}" = "true" ]] && ! gradle --version > /dev/null; then if [[ "${INSTALL_GRADLE}" = "true" ]] && ! gradle --version > /dev/null; then
sdk_install gradle ${GRADLE_VERSION} sdk_install gradle ${GRADLE_VERSION}
......
...@@ -8,8 +8,15 @@ source dev-container-features-test-lib ...@@ -8,8 +8,15 @@ source dev-container-features-test-lib
check "user is root" grep root <(whoami) check "user is root" grep root <(whoami)
check "java" java --version check "java" java --version
check "gradle" gradle --version
check "ant" ant -version
cat << EOF > /tmp/build.xml
<project><target name="init"><mkdir dir="ant-src"/></target></project>
EOF
cd /tmp && ant init
check "ant-src exists" grep "ant-src" <(ls -la /tmp)
check "gradle" gradle --version
cd /tmp && gradle init --type basic --dsl groovy --incubating --project-name test cd /tmp && gradle init --type basic --dsl groovy --incubating --project-name test
check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /root) check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /root)
......
...@@ -8,8 +8,15 @@ source dev-container-features-test-lib ...@@ -8,8 +8,15 @@ source dev-container-features-test-lib
check "user is vscode" grep vscode <(whoami) check "user is vscode" grep vscode <(whoami)
check "java" java --version check "java" java --version
check "gradle" gradle --version
check "ant" ant -version
cat << EOF > /tmp/build.xml
<project><target name="init"><mkdir dir="ant-src"/></target></project>
EOF
cd /tmp && ant init
check "ant-src exists" grep "ant-src" <(ls -la /tmp)
check "gradle" gradle --version
cd /tmp && gradle init --type basic --dsl groovy --incubating --project-name test cd /tmp && gradle init --type basic --dsl groovy --incubating --project-name test
check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /home/vscode) check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /home/vscode)
......
...@@ -8,8 +8,15 @@ source dev-container-features-test-lib ...@@ -8,8 +8,15 @@ source dev-container-features-test-lib
check "user is root" grep root <(whoami) check "user is root" grep root <(whoami)
check "java" java --version check "java" java --version
check "gradle version" grep "Gradle 6.8.3" <(gradle --version)
check "ant version" grep "Ant(TM) version 1.10.12" <(ant -version)
cat << EOF > /tmp/build.xml
<project><target name="init"><mkdir dir="ant-src"/></target></project>
EOF
cd /tmp && ant init
check "ant-src exists" grep "ant-src" <(ls -la /tmp)
check "gradle version" grep "Gradle 6.8.3" <(gradle --version)
cd /tmp && gradle init --type basic --dsl groovy --project-name test cd /tmp && gradle init --type basic --dsl groovy --project-name test
check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /root) check "GRADLE_USER_HOME exists" grep ".gradle" <(ls -la /root)
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
} }
} }
}, },
"install_gradle_and_maven_for_user": { "install_ant_and_gradle_and_maven_for_user": {
"image": "ubuntu:focal", "image": "ubuntu:focal",
"remoteUser": "vscode", "remoteUser": "vscode",
"features": { "features": {
...@@ -26,26 +26,30 @@ ...@@ -26,26 +26,30 @@
}, },
"java": { "java": {
"version": "latest", "version": "latest",
"installAnt": true,
"installGradle": true, "installGradle": true,
"installMaven": true "installMaven": true
} }
} }
}, },
"install_gradle_and_maven": { "install_ant_and_gradle_and_maven": {
"image": "ubuntu:focal", "image": "ubuntu:focal",
"features": { "features": {
"java": { "java": {
"version": "latest", "version": "latest",
"installAnt": true,
"installGradle": true, "installGradle": true,
"installMaven": true "installMaven": true
} }
} }
}, },
"install_gradle_and_maven_with_specific_version": { "install_ant_and_gradle_and_maven_with_specific_version": {
"image": "ubuntu:focal", "image": "ubuntu:focal",
"features": { "features": {
"java": { "java": {
"version": "latest", "version": "latest",
"installAnt": "true",
"antVersion": "1.10.12",
"installGradle": "true", "installGradle": "true",
"gradleVersion": "6.8.3", "gradleVersion": "6.8.3",
"installMaven": "true", "installMaven": "true",
......
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