Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test preview #19597

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dev via Gitpod Flex
  • Loading branch information
mustard-mh committed Jan 24, 2025
commit 489e534c3ab4561cb25f842b2ead0fd475e45ccf
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion components/ide/jetbrains/toolbox/README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,14 @@

Provides a way to connect to Gitpod Classic workspaces within the JetBrains Toolbox App.

## How to Develop
## How to Develop with Gitpod Flex

- Start an environment on [Gitpod Flex](https://app.gitpod.io) with current repository
- Connect to the environment via **JetBrains Gateway** (because we want to restart Toolbox) SSH feature (user: gitpod_devcontainer)
- [optional] Copy ./flex-sync.sh locally and chmod +x, the script is written for macOS, please adjust it if you're using other OS
- Exec `./flex-sync.sh <env_host>`

## How to Develop locally

### Requires
- Java 21
18 changes: 18 additions & 0 deletions components/ide/jetbrains/toolbox/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -146,6 +146,24 @@ val restartToolbox by tasks.creating {
}
}

val buildPluginFlex by tasks.creating(Sync::class.java) {
group = "01.Gitpod"

dependsOn(tasks.named("shadowJar"))
from(tasks.named("shadowJar").get().outputs.files)

val targetDir = Path.of("./build/flex") / pluginId

from("src/main/resources") {
include("extension.json")
include("dependencies.json")
include("icon.svg")
include("icon-gray.svg")
}

into(targetDir)
}

val copyPlugin by tasks.creating(Sync::class.java) {
group = "01.Gitpod"

45 changes: 45 additions & 0 deletions components/ide/jetbrains/toolbox/flex-sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# shellcheck disable=all
#
# Sync the local Toolbox plugins folder from the build results of Gitpod Flex (`build/flex/*`) automatically
# so that you could build with a remote environment

if [ $# -eq 0 ]; then
echo "Usage: $0 <remote_host>"
echo "Example: $0 01944f84-5bc8-7d9b-916a-4fc95e25de12.gitpod.environment"
exit 1
fi

REMOTE_HOST="$1"
LOCAL_DIR="$HOME/Library/Caches/JetBrains/Toolbox/plugins"
REMOTE_DIR="/workspace/gitpod/components/ide/jetbrains/toolbox/build/flex"
DEVCONTAINER_HOST="gitpod_devcontainer@$REMOTE_HOST"

echo "Preparing..."

ssh $DEVCONTAINER_HOST "apt-get update && apt-get install -y rsync inotify-tools" > /dev/null

function sync_and_restart() {
rsync -avz --delete "$DEVCONTAINER_HOST:$REMOTE_DIR/" "$LOCAL_DIR/"
pkill -f 'JetBrains Toolbox' || true
echo debugClean > $HOME/Library/Logs/JetBrains/Toolbox/toolbox.log
code $HOME/Library/Logs/JetBrains/Toolbox/toolbox.log
# In case Toolbox refuses to start
echo "Restarting Toolbox in 3 seconds"
sleep 3
open /Applications/JetBrains\ Toolbox.app
}

echo "Initing..."

sync_and_restart

echo "Watching for changes in $DEVCONTAINER_HOST:$REMOTE_DIR"

ssh $DEVCONTAINER_HOST "inotifywait -m -r -e modify,create,delete,move $REMOTE_DIR" | \
while read path action file; do
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Change detected: $action $file"
# Make sure remote is build
sleep 3
sync_and_restart
done