From f146bf9aebe3cabc9f1c304c09c59a391dbafe2a Mon Sep 17 00:00:00 2001 From: Kris foster Date: Thu, 21 Mar 2024 20:34:00 +0000 Subject: [PATCH] dynamic JAVA_HOME (#12) --- docker_compose/test_container_entrypoint.sh | 4 ++++ examples/junit-image-test/docker-compose.yml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/docker_compose/test_container_entrypoint.sh b/docker_compose/test_container_entrypoint.sh index 1bd1bc1..38b0760 100755 --- a/docker_compose/test_container_entrypoint.sh +++ b/docker_compose/test_container_entrypoint.sh @@ -13,8 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +# if JAVA_HOME is not set, just default to /usr (works if /usr/bin/java exists) if [[ -z "$JAVA_HOME" ]]; then JAVA_HOME="/usr" +# this is used if JAVA_HOME contains an * (if version changes regularly this can be useful) +elif [[ "$JAVA_HOME" == *"\*"* ]]; then + JAVA_HOME=$(find $JAVA_HOME -maxdepth 1 | head -n 1) fi TEST_UBER_JAR=$(find ./ -maxdepth 1 -name '*_uber_jar_deploy.jar') diff --git a/examples/junit-image-test/docker-compose.yml b/examples/junit-image-test/docker-compose.yml index b4fab10..8699f90 100644 --- a/examples/junit-image-test/docker-compose.yml +++ b/examples/junit-image-test/docker-compose.yml @@ -17,3 +17,5 @@ services: test_container: image: junit-image-test:test_container entrypoint: ["/busybox/sh", "./test_container_entrypoint.sh"] + environment: + - JAVA_HOME=/usr/ \ No newline at end of file