This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
.install-jdk-travis.sh
executable file
·78 lines (69 loc) · 2.33 KB
/
.install-jdk-travis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
install_jdk () {
if $jabba use $ACTUAL_JDK; then
echo $ACTUAL_JDK was available and Jabba is using it
else
echo installing $ACTUAL_JDK
$jabba install "$ACTUAL_JDK" || exit $?
echo setting $ACTUAL_JDK as Jabba default
$jabba use $ACTUAL_JDK || exit $?
fi
}
unix_pre () {
curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh
unset _JAVA_OPTIONS
export jabba=jabba
}
install_jabba_on_linux () {
unix_pre
}
install_jabba_on_osx () {
unix_pre
export JAVA_HOME="$HOME/.jabba/jdk/$ACTUAL_JDK/Contents/Home"
}
install_jabba_on_windows () {
PowerShell -ExecutionPolicy Bypass -Command '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-Expression (Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing).Content'
export jabba="$HOME/.jabba/bin/jabba.exe"
}
complete_installation_on_linux () {
echo
}
complete_installation_on_osx () {
export JAVA_HOME="$HOME/.jabba/jdk/$ACTUAL_JDK/Contents/Home"
}
complete_installation_on_windows () {
# Windows is unable to clean child processes, so no Gradle daemon allowed
export GRADLE_OPTS="-Dorg.gradle.daemon=false $GRADLE_OPTS"
echo 'export GRADLE_OPTS="-Dorg.gradle.daemon=false $GRADLE_OPTS"' >> ~/.jdk_config
}
retry() { eval "$*" || (eval "$*" || eval "$*"); }
set -e
if [ -z $JDK ]
then
echo "No JDK variable provided."
exit 1
fi
echo "running ${TRAVIS_OS_NAME}-specific configuration"
echo "installing Jabba"
retry install_jabba_on_$TRAVIS_OS_NAME
echo "Computing best match for required JDK version: $JDK"
ACTUAL_JDK="$(echo $($jabba ls-remote | grep -m1 $JDK))"
echo "Selected JDK: $ACTUAL_JDK"
if [ -z $ACTUAL_JDK ]
then
echo "No JDK version is compatible with $JDK. Available JDKs are:"
"$jabba" ls-remote
exit 2
else
echo "Best match is $ACTUAL_JDK"
export JAVA_HOME="$HOME/.jabba/jdk/$ACTUAL_JDK"
complete_installation_on_$TRAVIS_OS_NAME
export PATH="$JAVA_HOME/bin:$PATH"
# Apparently exported variables are ignored in subseguent phases on Windows. Write in config file
echo "export JAVA_HOME=\"${JAVA_HOME}\"" >> ~/.jdk_config
echo "export PATH=\"${PATH}\"" >> ~/.jdk_config
retry install_jdk
which java
java -Xmx32m -version
set +e
fi