mirror of
https://github.com/actions/runner-images.git
synced 2025-12-11 03:27:05 +00:00
Set javac version 1.8 on Ubuntu 16.04 (#1483)
* set up javac version * fix update-java-alternatives * add version check * change java check * fix checks and position of update-java-alternatives * resolve comments Co-authored-by: Dmitry Shibanov <v-dmshib@microsoft.com>
This commit is contained in:
@@ -10,6 +10,15 @@ source $HELPER_SCRIPTS/os.sh
|
||||
|
||||
set -e
|
||||
|
||||
function javaTool {
|
||||
if [[ "$2" =~ ([1]{0,1}.)?$DEFAULT_JDK_VERSION.* ]]; then
|
||||
echo "$1 $2 is equal to default one $DEFAULT_JDK_VERSION"
|
||||
else
|
||||
echo "$1 $2 is not equal to default one $DEFAULT_JDK_VERSION"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Install GPG Key for Adopt Open JDK. See https://adoptopenjdk.net/installation.html
|
||||
wget -qO - "https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public" | apt-key add -
|
||||
add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
|
||||
@@ -38,6 +47,11 @@ apt-get -y install adoptopenjdk-8-hotspot=\*
|
||||
apt-get -y install adoptopenjdk-11-hotspot=\*
|
||||
|
||||
# Set Default Java version.
|
||||
if isUbuntu16; then
|
||||
# issue: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825987
|
||||
# stackoverflow: https://askubuntu.com/questions/1187136/update-java-alternatives-only-java-but-not-javac-is-changed
|
||||
sed -i 's/(hl|jre|jdk|plugin|DUMMY) /(hl|jre|jdk|jdkhl|plugin|DUMMY) /g' /usr/sbin/update-java-alternatives
|
||||
fi
|
||||
update-java-alternatives -s /usr/lib/jvm/adoptopenjdk-${DEFAULT_JDK_VERSION}-hotspot-amd64
|
||||
|
||||
echo "JAVA_HOME_8_X64=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64" | tee -a /etc/environment
|
||||
@@ -85,6 +99,11 @@ for cmd in gradle java javac mvn ant; do
|
||||
fi
|
||||
done
|
||||
|
||||
javaVersion=$(java -version |& head -n 1 | cut -d\" -f 2)
|
||||
javaTool "Java" $javaVersion
|
||||
javacVersion=$(javac -version |& cut -d" " -f2)
|
||||
javaTool "Javac" $javacVersion
|
||||
|
||||
# Document what was added to the image
|
||||
echo "Lastly, documenting what we added to the metadata file"
|
||||
if isUbuntu16 || isUbuntu18 ; then
|
||||
|
||||
Reference in New Issue
Block a user