-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-jdk.sh
executable file
·133 lines (118 loc) · 4.17 KB
/
init-jdk.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
#
# Download JetBrains JDK including JCEF for development & deployment.
#
# -------------------------------------------------------------------
#
# Copyright (c) 2024-2025 Andreas Rudolph <[email protected]>.
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# The application uses the Jetbrains JDK bundled with JCEF.
# see https://github.com/JetBrains/JetBrainsRuntime
# see https://github.com/JetBrains/JetBrainsRuntime/releases
#
# Due to a build problem on MacOS,
# we're currently using the older version "21.0.5b509.30".
# see https://github.com/JetBrains/JetBrainsRuntime/issues/490
#
JBR_VERSION="21.0.5b509.30"
set -e
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
JDK_DIR="${BASE_DIR}/jdk"
mkdir -p "${JDK_DIR}"
cd "${JDK_DIR}"
JDK_VERSION="$(echo "${JBR_VERSION}" | cut -d "b" -f 1)"
#echo "${JDK_VERSION}"
JDK_BUILD="$(echo "${JBR_VERSION}" | cut -d "b" -f 2)"
#echo "${JDK_BUILD}"
case "$(uname -s)" in
Linux*) SYSTEM="linux";;
Darwin*) SYSTEM="osx";;
CYGWIN*) SYSTEM="windows";;
MINGW*) SYSTEM="windows";;
*) SYSTEM=""
esac
if [ -z "${SYSTEM}" ]; then
echo "Unsupported operating system: $(uname -s)"
exit 1
fi
case "$(uname -m)" in
aarch64*) ARCH="aarch64";;
arm64*) ARCH="aarch64";;
x86_64*) ARCH="x64";;
*) ARCH=""
esac
if [ -z "${ARCH}" ]; then
echo "Unsupported system architecture: $(uname -m)"
exit 1
fi
echo ""
echo "==================================================================="
echo ""
echo "Init JetBrains JDK for \"${SYSTEM}-${ARCH}\"..."
# Download links at https://github.com/JetBrains/JetBrainsRuntime/releases
BASE_NAME="jbrsdk_jcef-${JDK_VERSION}-${SYSTEM}-${ARCH}-b${JDK_BUILD}"
DOWNLOAD_URL="https://cache-redirector.jetbrains.com/intellij-jbr/${BASE_NAME}.tar.gz"
DOWNLOAD_DIR="${JDK_DIR}/${BASE_NAME}"
DOWNLOAD_FILE="${JDK_DIR}/${BASE_NAME}.tar.gz"
if [ ! -d "${DOWNLOAD_DIR}" ]; then
if [ ! -f "${DOWNLOAD_FILE}" ]; then
echo "Downloading from \"${DOWNLOAD_URL}\"..."
wget -q "${DOWNLOAD_URL}"
fi
echo "Extracting archive..."
tar xfz "${DOWNLOAD_FILE}"
if [ ! -d "${DOWNLOAD_DIR}" ]; then
echo "Expected JDK directory does not exist at \"${DOWNLOAD_DIR}\"!"
exit 1
fi
# Remove Apple quarantine attributes. Not sure if necessary, but it doesn't hurt.
if [ "${SYSTEM}" = "osx" ]; then
echo "Remove Apple quarantine attributes. This might require authentication as admin user..."
sudo xattr -r -d com.apple.quarantine "${DOWNLOAD_DIR}"
fi
fi
echo "Writing environment variables..."
JAVA_HOME="${DOWNLOAD_DIR}"
if [ "${SYSTEM}" = "osx" ]; then
JAVA_HOME="${JAVA_HOME}/Contents/Home"
fi
echo "#" > "${BASE_DIR}/env.sh"
# shellcheck disable=SC2129
echo "# This file was automatically generated by \"init-jdk.sh\"." >> "${BASE_DIR}/env.sh"
echo "# It is automatically updated, if \"init-jdk.sh\" is executed." >> "${BASE_DIR}/env.sh"
echo "#" >> "${BASE_DIR}/env.sh"
echo "" >> "${BASE_DIR}/env.sh"
echo "export JAVA_HOME=\"${JAVA_HOME}\"" >> "${BASE_DIR}/env.sh"
echo "export PATH=\"${JAVA_HOME}/bin:${PATH}\"" >> "${BASE_DIR}/env.sh"
chmod ugo+x "${BASE_DIR}/env.sh"
echo ""
echo "==================================================================="
echo ""
echo "JetBrains JDK was downloaded into:"
echo ""
echo "${DOWNLOAD_DIR}"
echo ""
echo "Please update your JAVA_HOME and IDE settings accordingly or use:"
echo ""
echo "${BASE_DIR}/env.sh"
echo ""
echo "==================================================================="
echo ""