Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ide/jetbrains/backend-plugin/launch-dev-server.sh
2500 views
1
#!/bin/bash
2
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
# Licensed under the GNU Affero General Public License (AGPL).
4
# See License.AGPL.txt in the project root for license information.
5
6
set -e
7
set -o pipefail
8
9
# Default Options
10
DEBUG_PORT=44444
11
JB_QUALIFIER="latest"
12
TEST_REPO=https://github.com/gitpod-samples/spring-petclinic
13
RUN_FROM="release"
14
15
# Parsing Custom Options
16
while getopts "p:r:su" OPTION
17
do
18
case $OPTION in
19
s) JB_QUALIFIER="stable" ;;
20
r) TEST_REPO=$OPTARG ;;
21
p) DEBUG_PORT=$OPTARG ;;
22
u) RUN_FROM="snapshot" ;;
23
*) ;;
24
esac
25
done
26
27
TEST_BACKEND_DIR="/workspace/ide-backend-$JB_QUALIFIER"
28
if [ ! -d "$TEST_BACKEND_DIR" ]; then
29
mkdir -p $TEST_BACKEND_DIR
30
if [[ $RUN_FROM == "snapshot" ]]; then
31
SNAPSHOT_VERSION=$(grep "platformVersion=" "gradle-$JB_QUALIFIER.properties" | sed 's/platformVersion=//')
32
(cd $TEST_BACKEND_DIR &&
33
echo "Downloading the $JB_QUALIFIER version of IntelliJ IDEA ($SNAPSHOT_VERSION)..." &&
34
curl -sSLo backend.zip "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/$SNAPSHOT_VERSION/ideaIU-$SNAPSHOT_VERSION.zip" &&
35
unzip backend.zip &&
36
rm backend.zip &&
37
ln -s "ideaIU-$SNAPSHOT_VERSION" . &&
38
rm -r "ideaIU-$SNAPSHOT_VERSION" &&
39
cp -r /ide-desktop/backend/jbr . &&
40
cp ./bin/linux/idea.properties ./bin &&
41
cp ./bin/linux/idea64.vmoptions ./bin)
42
else
43
if [[ $JB_QUALIFIER == "stable" ]]; then
44
PRODUCT_TYPE="release"
45
else
46
PRODUCT_TYPE="release,rc,eap"
47
fi
48
(cd $TEST_BACKEND_DIR &&
49
echo "Downloading the $JB_QUALIFIER version of IntelliJ IDEA..." &&
50
curl -sSLo backend.tar.gz "https://download.jetbrains.com/product?type=$PRODUCT_TYPE&distribution=linux&code=IIU" &&
51
tar -xf backend.tar.gz --strip-components=1 &&
52
rm backend.tar.gz)
53
fi
54
fi
55
56
TEST_PLUGINS_DIR="$TEST_BACKEND_DIR/plugins"
57
TEST_PLUGIN_DIR="$TEST_PLUGINS_DIR/gitpod-remote"
58
rm -rf $TEST_PLUGIN_DIR
59
60
GITPOD_PLUGIN_DIR=/workspace/gitpod/components/ide/jetbrains/backend-plugin
61
$GITPOD_PLUGIN_DIR/gradlew -PenvironmentName="$JB_QUALIFIER" buildPlugin
62
63
# TODO(ak) actually should be gradle task to make use of output
64
GITPOD_PLUGIN_DIST="$GITPOD_PLUGIN_DIR/build/distributions/gitpod-remote.zip"
65
unzip $GITPOD_PLUGIN_DIST -d $TEST_PLUGINS_DIR
66
rm -rf "$TEST_PLUGINS_DIR/plugin-classpath.txt"
67
68
TEST_REPO_NAME=$(basename "$TEST_REPO")
69
TEST_DIR=/workspace/$TEST_REPO_NAME
70
if [ ! -d "$TEST_DIR" ]; then
71
git clone "$TEST_REPO" "$TEST_DIR"
72
fi
73
74
export JB_DEV=true
75
export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:$DEBUG_PORT"
76
77
# Set default config and system directories under /workspace to preserve between restarts
78
export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains
79
export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains
80
81
# Enable host status endpoint
82
export CWM_HOST_STATUS_OVER_HTTP_TOKEN=gitpod
83
84
# Build and move idea-cli, then overwrite environment variables initially defined by `components/ide/jetbrains/image/leeway.Dockerfile`
85
# Note: IDEA_CLI_DEV_PATH path needs to be the same string used in components/ide/jetbrains/cli/cmd/root.go
86
IDEA_CLI_DEV_PATH=/ide-desktop/bin/idea-cli-dev
87
(cd ../cli && go build -o $IDEA_CLI_DEV_PATH)
88
export EDITOR="$IDEA_CLI_DEV_PATH open"
89
export VISUAL="$EDITOR"
90
export GP_OPEN_EDITOR="$EDITOR"
91
export GIT_EDITOR="$EDITOR --wait"
92
export GP_PREVIEW_BROWSER="$IDEA_CLI_DEV_PATH preview"
93
export GP_EXTERNAL_BROWSER="$IDEA_CLI_DEV_PATH preview"
94
95
export JETBRAINS_GITPOD_BACKEND_KIND=intellij
96
97
$TEST_BACKEND_DIR/bin/remote-dev-server.sh run "$TEST_DIR"
98
99