From a37a5ecb4b49c39ee51e0c8d1fd16ebdb6faf799 Mon Sep 17 00:00:00 2001 From: Huiwen Date: Fri, 13 Dec 2024 11:08:01 +0000 Subject: [PATCH 1/3] Add JetBrains projects proto on the schema --- components/gitpod-protocol/data/gitpod-schema.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/gitpod-protocol/data/gitpod-schema.json b/components/gitpod-protocol/data/gitpod-schema.json index 98f0c42e50dfae..7a6e5525eac33e 100644 --- a/components/gitpod-protocol/data/gitpod-schema.json +++ b/components/gitpod-protocol/data/gitpod-schema.json @@ -266,6 +266,15 @@ "type": "string" } }, + "projects": { + "type": "array", + "description": "List of additional projects that the JetBrains editor would open", + "additionalProperties": false, + "items": { + "type": "string", + "description": "Project absolute path" + } + }, "intellij": { "$ref": "#/definitions/jetbrainsProduct", "description": "Configure IntelliJ integration" From eed1d00357816f03582d2dfa8ce07ab075e9acdc Mon Sep 17 00:00:00 2001 From: Huiwen Date: Fri, 13 Dec 2024 11:08:16 +0000 Subject: [PATCH 2/3] Update types --- components/gitpod-protocol/go/gitpod-config-types.go | 3 +++ components/gitpod-protocol/src/protocol.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/components/gitpod-protocol/go/gitpod-config-types.go b/components/gitpod-protocol/go/gitpod-config-types.go index 011723a58ee283..045f904abeee75 100644 --- a/components/gitpod-protocol/go/gitpod-config-types.go +++ b/components/gitpod-protocol/go/gitpod-config-types.go @@ -112,6 +112,9 @@ type Jetbrains struct { // List of plugins which should be installed for all JetBrains product for users of this workspace. From the JetBrains Marketplace page, find a page of the required plugin, select 'Versions' tab, click any version to copy pluginId (short name such as org.rust.lang) of the plugin you want to install. Plugins []string `yaml:"plugins,omitempty" json:"plugins,omitempty"` + // List of additional projects that the JetBrains editor would open + Projects []string `yaml:"projects,omitempty" json:"projects,omitempty"` + // Configure PyCharm integration Pycharm *JetbrainsProduct `yaml:"pycharm,omitempty" json:"pycharm,omitempty"` diff --git a/components/gitpod-protocol/src/protocol.ts b/components/gitpod-protocol/src/protocol.ts index 59a3f23e1cecdb..42b8930aa74449 100644 --- a/components/gitpod-protocol/src/protocol.ts +++ b/components/gitpod-protocol/src/protocol.ts @@ -767,6 +767,10 @@ export interface JetBrainsConfig { rider?: JetBrainsProductConfig; clion?: JetBrainsProductConfig; rustrover?: JetBrainsProductConfig; + /** + * List of additonal projects that JetBrains editor would open with + */ + projects?: string[]; } export interface JetBrainsProductConfig { prebuilds?: JetBrainsPrebuilds; From a4684ce43e66756f9080c8a0023fa43cd3657946 Mon Sep 17 00:00:00 2001 From: Huiwen Date: Fri, 13 Dec 2024 11:24:19 +0000 Subject: [PATCH 3/3] Launch additional project --- components/ide/jetbrains/launcher/main.go | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/components/ide/jetbrains/launcher/main.go b/components/ide/jetbrains/launcher/main.go index cd6074558badc5..a68829ba16e36d 100644 --- a/components/ide/jetbrains/launcher/main.go +++ b/components/ide/jetbrains/launcher/main.go @@ -602,6 +602,14 @@ func launch(launchCtx *LaunchContext) { log.WithError(err).Error("failed to install gitpod-remote plugin") } + go func(launchCtx *LaunchContext, additonalProjects []string) { + // TODO: wait until backend is healthy + time.Sleep(5 * time.Second) + for _, project := range additonalProjects { + go appendAdditonalProject(launchCtx, project) + } + }(launchCtx, gitpodConfig.Jetbrains.Projects) + // run backend run(launchCtx) } @@ -640,6 +648,31 @@ func run(launchCtx *LaunchContext) { os.Exit(cmd.ProcessState.ExitCode()) } +func appendAdditonalProject(launchCtx *LaunchContext, projectLocation string) { + var args []string + if launchCtx.warmup { + args = append(args, "warmup") + } else if launchCtx.preferToolbox { + args = append(args, "serverMode") + } else { + args = append(args, "run") + } + args = append(args, projectLocation) + + cmd := remoteDevServerCmd(args, launchCtx) + // Enable host status endpoint + cmd.Env = append(cmd.Env, "CWM_HOST_STATUS_OVER_HTTP_TOKEN=gitpod") + + if err := cmd.Start(); err != nil { + log.WithError(err).Error("failed to start") + } + + err := cmd.Wait() + if err != nil { + log.Warn("faild to start additional project", log.WithField("project", projectLocation), log.WithError(err)) + } +} + // resolveUserEnvs emulats the interactive login shell to ensure that all user defined shell scripts are loaded func resolveUserEnvs() (userEnvs []string, err error) { shell := os.Getenv("SHELL") @@ -1113,6 +1146,7 @@ func installPlugins(config *gitpod.GitpodConfig, launchCtx *LaunchContext) error var args []string args = append(args, "installPlugins") + // TODO(hw): Do we need project path here? args = append(args, launchCtx.projectContextDir) args = append(args, plugins...) cmd := remoteDevServerCmd(args, launchCtx)