Path: blob/main/components/ide/jetbrains/backend-plugin/launch-dev-server.sh
2500 views
#!/bin/bash1# Copyright (c) 2022 Gitpod GmbH. All rights reserved.2# Licensed under the GNU Affero General Public License (AGPL).3# See License.AGPL.txt in the project root for license information.45set -e6set -o pipefail78# Default Options9DEBUG_PORT=4444410JB_QUALIFIER="latest"11TEST_REPO=https://github.com/gitpod-samples/spring-petclinic12RUN_FROM="release"1314# Parsing Custom Options15while getopts "p:r:su" OPTION16do17case $OPTION in18s) JB_QUALIFIER="stable" ;;19r) TEST_REPO=$OPTARG ;;20p) DEBUG_PORT=$OPTARG ;;21u) RUN_FROM="snapshot" ;;22*) ;;23esac24done2526TEST_BACKEND_DIR="/workspace/ide-backend-$JB_QUALIFIER"27if [ ! -d "$TEST_BACKEND_DIR" ]; then28mkdir -p $TEST_BACKEND_DIR29if [[ $RUN_FROM == "snapshot" ]]; then30SNAPSHOT_VERSION=$(grep "platformVersion=" "gradle-$JB_QUALIFIER.properties" | sed 's/platformVersion=//')31(cd $TEST_BACKEND_DIR &&32echo "Downloading the $JB_QUALIFIER version of IntelliJ IDEA ($SNAPSHOT_VERSION)..." &&33curl -sSLo backend.zip "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/$SNAPSHOT_VERSION/ideaIU-$SNAPSHOT_VERSION.zip" &&34unzip backend.zip &&35rm backend.zip &&36ln -s "ideaIU-$SNAPSHOT_VERSION" . &&37rm -r "ideaIU-$SNAPSHOT_VERSION" &&38cp -r /ide-desktop/backend/jbr . &&39cp ./bin/linux/idea.properties ./bin &&40cp ./bin/linux/idea64.vmoptions ./bin)41else42if [[ $JB_QUALIFIER == "stable" ]]; then43PRODUCT_TYPE="release"44else45PRODUCT_TYPE="release,rc,eap"46fi47(cd $TEST_BACKEND_DIR &&48echo "Downloading the $JB_QUALIFIER version of IntelliJ IDEA..." &&49curl -sSLo backend.tar.gz "https://download.jetbrains.com/product?type=$PRODUCT_TYPE&distribution=linux&code=IIU" &&50tar -xf backend.tar.gz --strip-components=1 &&51rm backend.tar.gz)52fi53fi5455TEST_PLUGINS_DIR="$TEST_BACKEND_DIR/plugins"56TEST_PLUGIN_DIR="$TEST_PLUGINS_DIR/gitpod-remote"57rm -rf $TEST_PLUGIN_DIR5859GITPOD_PLUGIN_DIR=/workspace/gitpod/components/ide/jetbrains/backend-plugin60$GITPOD_PLUGIN_DIR/gradlew -PenvironmentName="$JB_QUALIFIER" buildPlugin6162# TODO(ak) actually should be gradle task to make use of output63GITPOD_PLUGIN_DIST="$GITPOD_PLUGIN_DIR/build/distributions/gitpod-remote.zip"64unzip $GITPOD_PLUGIN_DIST -d $TEST_PLUGINS_DIR65rm -rf "$TEST_PLUGINS_DIR/plugin-classpath.txt"6667TEST_REPO_NAME=$(basename "$TEST_REPO")68TEST_DIR=/workspace/$TEST_REPO_NAME69if [ ! -d "$TEST_DIR" ]; then70git clone "$TEST_REPO" "$TEST_DIR"71fi7273export JB_DEV=true74export JAVA_TOOL_OPTIONS="$JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=127.0.0.1:$DEBUG_PORT"7576# Set default config and system directories under /workspace to preserve between restarts77export IJ_HOST_CONFIG_BASE_DIR=/workspace/.config/JetBrains78export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains7980# Enable host status endpoint81export CWM_HOST_STATUS_OVER_HTTP_TOKEN=gitpod8283# Build and move idea-cli, then overwrite environment variables initially defined by `components/ide/jetbrains/image/leeway.Dockerfile`84# Note: IDEA_CLI_DEV_PATH path needs to be the same string used in components/ide/jetbrains/cli/cmd/root.go85IDEA_CLI_DEV_PATH=/ide-desktop/bin/idea-cli-dev86(cd ../cli && go build -o $IDEA_CLI_DEV_PATH)87export EDITOR="$IDEA_CLI_DEV_PATH open"88export VISUAL="$EDITOR"89export GP_OPEN_EDITOR="$EDITOR"90export GIT_EDITOR="$EDITOR --wait"91export GP_PREVIEW_BROWSER="$IDEA_CLI_DEV_PATH preview"92export GP_EXTERNAL_BROWSER="$IDEA_CLI_DEV_PATH preview"9394export JETBRAINS_GITPOD_BACKEND_KIND=intellij9596$TEST_BACKEND_DIR/bin/remote-dev-server.sh run "$TEST_DIR"979899