forked from DanySK/Gravis-CI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-jdk
112 lines (99 loc) · 3.68 KB
/
install-jdk
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/echo This script needs to be sourced, not executed!
# shellcheck disable=SC2096
# shellcheck shell=bash
install_jdk () {
if [ "$GRAVIS_CI_PREFER_CACHE" = "TRUE" ] && jabba use "$ACTUAL_JDK"
then
echo "Gravis-CI $ACTUAL_JDK was available and Jabba is using it"
else
echo "Gravis-CI installing $ACTUAL_JDK"
jabba install "$ACTUAL_JDK"
jabba install "$ACTUAL_JDK"
jabba install "$ACTUAL_JDK"
echo "Gravis-CI setting $ACTUAL_JDK as Jabba default"
jabba use "$ACTUAL_JDK" || exit $?
fi
}
unix_pre () {
if [ "$GRAVIS_CI_PREFER_CACHE" = "TRUE" ] && [ -d ~/.jabba ] && [ -f ~/.jabba/jabba.sh ]; then
echo "Gravis-CI Using existing Jabba installation"
else
echo "Gravis-CI Downloading Jabba installation script"
mkdir -p ~/.gravis-ci
travis_retry eval "\
curl -sSL --retry-delay 60 --retry 10\
https://raw.githubusercontent.com/shyiko/jabba/master/install.sh --output ~/.gravis-ci/install-jabba.sh\
&& bash ~/.gravis-ci/install-jabba.sh\
"
fi
echo "Gravis-CI Sourcing jabba.sh"
travis_retry source ~/.jabba/jabba.sh
unset _JAVA_OPTIONS
}
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 () {
export PATH="$HOME/.jabba/bin/:$PATH"
echo "Gravis-CI Running Jabba installation on Windows"
POWERSHELL_COMMAND="PowerShell -ExecutionPolicy Bypass -Command '
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
Invoke-Expression (
Invoke-WebRequest https://raw.githubusercontent.com/shyiko/jabba/master/install.ps1 -UseBasicParsing
).Content'"
travis_retry eval "$POWERSHELL_COMMAND && jabba"
echo "Gravis-CI Indirect installation via PowerShell completed"
}
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 "Gravis-CI running ${TRAVIS_OS_NAME}-specific configuration"
if [ "$GRAVIS_CI_PREFER_CACHE" = "TRUE" ];
then
echo "Gravis-CI configured for GRAVIS_CI_PREFER_CACHE mode TRUE"
else
echo "Gravis-CI not configured for GRAVIS_CI_PREFER_CACHE mode FALSE"
GRAVIS_CI_PREFER_CACHE=FALSE
fi
echo "Gravis-CI installing Jabba"
install_jabba_on_"$TRAVIS_OS_NAME"
jabba || echo "Jabba installation failed" && false
JDK=${JDK:-"."}
# It is possible we have already installed a compatible JDK. Check local first
# in an attempt to avoid a possible remote list failure
echo "Gravis-CI Checking for existing local install compatible with $JDK"
ACTUAL_JDK="$(travis_retry jabba ls > >(grep -m1 "$JDK"))"
echo "Gravis-CI Detected possible local JDK match: $ACTUAL_JDK"
if [ -z "$ACTUAL_JDK" ]
then
echo "Gravis-CI did not find compatible existing local install"
echo "Gravis-CI Computing best match for required JDK version: $JDK"
# shellcheck disable=SC2046
ACTUAL_JDK="$(travis_retry jabba ls-remote > >(grep -m1 "$JDK"))"
echo "Gravis-CI Selected JDK: $ACTUAL_JDK"
if [ -z "$ACTUAL_JDK" ]
then
echo "Gravis-CI No JDK version is compatible with $JDK. Available JDKs are:"
jabba ls-remote
exit 2
fi
fi
echo "Gravis-CI Using best match: $ACTUAL_JDK"
export JAVA_HOME="$HOME/.jabba/jdk/$ACTUAL_JDK"
complete_installation_on_"$TRAVIS_OS_NAME"
export PATH="$JAVA_HOME/bin:$PATH"
install_jdk
which java
java -Xmx32m -version
jabba current | grep "$JDK"