Skip to content

Commit a679284

Browse files
authored
Add Java Development Environment 21 (#58)
Some tools (specifically PlantUML in this case) require a JDK, hence we install it. Bazel's rules_java requires that JAVA_HOME is set appropriately, so we do that as well.
1 parent 3f65af4 commit a679284

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

src/s-core-devcontainer/.devcontainer/s-core-local/install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ apt-get install -y python${python_version} python3-pip python3-venv
4141
# devcontainer feature "python" (cf. https://github.com/devcontainers/features/tree/main/src/python )
4242
apt-get install -y flake8 python3-autopep8 black python3-yapf mypy pydocstyle pycodestyle bandit pipenv virtualenv python3-pytest pylint
4343

44+
# OpenJDK 21, via APT
45+
# Set JAVA_HOME environment variable system-wide, since some tools rely on it (e.g., Bazel's rules_java)
46+
apt-get install -y openjdk-21-jdk-headless="${openjdk_21_version}*"
47+
export JAVA_HOME="$(dirname $(dirname $(realpath $(which javac))))"
48+
echo "export JAVA_HOME=\"$(dirname $(dirname $(realpath $(which javac))))\"" > /etc/profile.d/java_home.sh
49+
4450
# Bazelisk, directly from GitHub
4551
# Using the existing devcontainer feature is not optimal:
4652
# - it does not check the SHA256 checksum of the downloaded file

src/s-core-devcontainer/.devcontainer/s-core-local/tests/test_default.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ check "validate buildifier is working and has the correct version" bash -c "buil
4141
check "validate starpls is working and has the correct version" bash -c "starpls version | grep '${starpls_version}'"
4242
check "validate bazel-compile-commands is working and has the correct version" bash -c "bazel-compile-commands --version 2>&1 | grep '${bazel_compile_commands_version}'"
4343

44+
# OpenJDK
45+
check "validate java is working and has the correct version" bash -c "java -version 2>&1 | grep '${openjdk_21_version}'"
46+
check "validate JAVA_HOME is set correctly" bash -c 'echo $JAVA_HOME | xargs readlink -f | grep "java-21-openjdk"'
47+
4448
# additional developer tools
4549
check "validate gdb is working and has the correct version" bash -c "gdb --version | grep '${gdb_version}'"
4650
check "validate gh is working and has the correct version" bash -c "gh --version | grep '${gh_version}'"

src/s-core-devcontainer/.devcontainer/s-core-local/versions.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ gdb:
2525
gh:
2626
version: "2.45.0"
2727

28+
openjdk_21:
29+
version: "21.0.9"
30+
2831
bazel:
2932
# https://github.com/bazelbuild/bazel/releases -- latest version as of 2025-09-24
3033
version: 8.4.1

scripts/test-utils.sh renamed to src/s-core-devcontainer/test-project/test-utils.sh

File renamed without changes.

src/s-core-devcontainer/test-project/test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ set -euo pipefail
33

44
SCRIPT_PATH=$(readlink -f "$0")
55
SCRIPT_DIR=$(dirname -- "${SCRIPT_PATH}")
6-
source "${SCRIPT_DIR}/../../../scripts/test-utils.sh" vscode
6+
7+
source "test-utils.sh" vscode
78

89
# C++ tooling
910
check "validate clangd is working and has the correct version" bash -c "clangd --version | grep '20.1.8'"

0 commit comments

Comments
 (0)