Browse Source

Move the run-java "--release" check to the wrapper script so it works in Windows too

Tianon Gravi 5 years ago
parent
commit
050d47dfd8
1 changed files with 7 additions and 2 deletions
  1. 7 2
      test/tests/run-java-in-container.sh

+ 7 - 2
test/tests/run-java-in-container.sh

@@ -38,13 +38,18 @@ if [ "$jdk" != "${tryJdks[0]}" ]; then
 	echo >&2 "warning: using '$jdk' instead of '${tryJdks[0]}' (results may vary!)"
 fi
 
+# if possible, use "--release" in case $jdk and $image have mismatching Java versions
+javac='javac'
+if docker run --rm "$jdk" java --help 2>&1 | grep -q -- '--release'; then
+	javac='javac --release 8'
+fi
+
 newImage="$("$runDir/image-name.sh" librarytest/java-hello-world "$image")"
 "$runDir/docker-build.sh" "$testDir" "$newImage" <<EOD
 FROM $jdk AS jdk
 WORKDIR /container
 COPY dir/container.java ./
-# if possible, use "--release" in case $jdk and $image have mismatching Java versions
-RUN if javac --help 2>&1 | grep -q -- '--release'; then javac --release 8 ./container.java; else javac ./container.java; fi
+RUN $javac ./container.java
 FROM $image
 COPY --from=jdk /container /container
 WORKDIR /container