Read Java version number even if it's not on the 1st line

Handles output like:

    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
    java version "1.8.0_31"

Fixes #710
This commit is contained in:
Mislav Marohnić 2015-01-21 16:51:29 -08:00
parent f674efd603
commit 7f1d8df3fe
2 changed files with 13 additions and 1 deletions

View file

@ -687,7 +687,7 @@ fix_rbx_irb() {
}
require_java7() {
local version="$(java -version 2>&1 | head -1)"
local version="$(java -version 2>&1 | grep 'java version' | head -1)"
if [[ $version != *1.[789]* ]]; then
colorize 1 "ERROR" >&3
echo ": Java 7 required. Please install a 1.7-compatible JRE." >&3

View file

@ -589,6 +589,18 @@ DEF
assert_success
}
@test "Java version string not on first line" {
cached_tarball "jruby-9000.dev" bin/jruby
stub java "-version : echo 'Picked up JAVA_TOOL_OPTIONS' >&2; echo 'java version \"1.8.0_31\"' >&2"
run_inline_definition <<DEF
require_java7
install_package "jruby-9000.dev" "http://ci.jruby.org/jruby-dist-9000.dev-bin.tar.gz" jruby
DEF
assert_success
}
@test "non-writable TMPDIR aborts build" {
export TMPDIR="${TMP}/build"
mkdir -p "$TMPDIR"