Skip to content

Commit

Permalink
Migrate to 2.6.0.35616
Browse files Browse the repository at this point in the history
  • Loading branch information
mustard-mh committed Dec 19, 2024
1 parent 59e19e5 commit d7b680a
Show file tree
Hide file tree
Showing 29 changed files with 287 additions and 126 deletions.
30 changes: 30 additions & 0 deletions components/ide/jetbrains/toolbox/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
packages:
- name: plugin-stable
type: generic
deps:
- components/supervisor-api/java:lib
- components/public-api/java:lib
srcs:
- "**/*.kt"
- "**/*.kts"
- src/main/resources/*
- gradle.properties
- gradlew
- gradle/*
- build.sh
env:
- JB_QUALIFIER=stable
- SDKMAN_DIR=/home/gitpod/.sdkman
config:
commands:
- - "bash"
- "-c"
- >
echo java=21.0.3.fx-zulu > .sdkmanrc
&& source "$SDKMAN_DIR/bin/sdkman-init.sh"
&& sdk env install
&& ./build.sh "0.0.1-${version}"
&& mv ./build/distributions/io.gitpod.toolbox.gateway.zip .toolbox.zip
&& rm -rf *
&& rm -rf .gradle .kotlin .sdkmanrc
&& mv .toolbox.zip toolbox.zip
29 changes: 24 additions & 5 deletions components/ide/jetbrains/toolbox/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import com.github.jk1.license.render.JsonReportRenderer
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.nio.file.Path
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import kotlin.io.path.div


plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.serialization)
`java-library`
alias(libs.plugins.dependency.license.report)
id("com.github.johnrengelman.shadow") version "8.1.1"
alias(libs.plugins.gradle.wrapper)
}

buildscript {
Expand All @@ -25,7 +29,17 @@ buildscript {

repositories {
mavenCentral()
maven("https://packages.jetbrains.team/maven/p/tbx/gateway")
maven("https://packages.jetbrains.team/maven/p/tbx/toolbox-api")
}

jvmWrapper {
unixJvmInstallDir = "jvm"
winJvmInstallDir = "jvm"
linuxAarch64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-linux-aarch64-b631.28.tar.gz"
linuxX64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-linux-x64-b631.28.tar.gz"
macAarch64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-osx-aarch64-b631.28.tar.gz"
macX64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-osx-x64-b631.28.tar.gz"
windowsX64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-windows-x64-b631.28.tar.gz"
}

dependencies {
Expand All @@ -47,16 +61,19 @@ dependencies {
// RD-Core https://mvnrepository.com/artifact/com.jetbrains.rd/rd-core
implementation("com.jetbrains.rd:rd-core:2024.1.1")

implementation(libs.gateway.api)
compileOnly(libs.bundles.toolbox.plugin.api)
// implementation(libs.gateway.api)
implementation(libs.slf4j)
implementation(libs.bundles.serialization)
implementation(libs.coroutines.core)
implementation(libs.okhttp)
}


val pluginId = "io.gitpod.toolbox.gateway"
val pluginVersion = "0.0.1-dev"
val defaultVersion = "0.0.1-local-${LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMddHHmm"))}"
val pluginVersion = providers.gradleProperty("pluginVersion").map { it.ifBlank { defaultVersion } }.getOrElse(defaultVersion)

println("Plugin version: $pluginVersion")

tasks.shadowJar {
archiveBaseName.set(pluginId)
Expand Down Expand Up @@ -156,6 +173,7 @@ val copyPlugin by tasks.creating(Sync::class.java) {
include("extension.json")
include("dependencies.json")
include("icon.svg")
include("icon-gray.svg")
}

into(targetDir)
Expand All @@ -173,9 +191,10 @@ val pluginZip by tasks.creating(Zip::class) {
}
from("src/main/resources") {
include("icon.svg")
include("icon-gray.svg")
rename("icon.svg", "pluginIcon.svg")
}
archiveBaseName.set("$pluginId-$pluginVersion")
archiveBaseName.set(pluginId)
}

val uploadPlugin by tasks.creating {
Expand Down
17 changes: 17 additions & 0 deletions components/ide/jetbrains/toolbox/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# Copyright (c) 2024 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.

set -e

JB_GP_VERSION=${1}

./gradlew -PsupervisorApiProjectPath=components-supervisor-api-java--lib/ -PgitpodPublicApiProjectPath=components-public-api-java--lib/ -PenvironmentName="$JB_QUALIFIER" -Dgradle.user.home="/workspace/.gradle-tb-$JB_QUALIFIER" -Dplugin.verifier.home.dir="$HOME/.cache/pluginVerifier-tb-$JB_QUALIFIER" -PpluginVersion="$JB_GP_VERSION" pluginZip

# # TODO(hw): Improve me
# tarDir="/tmp/tb-build"
# mkdir -p "$tarDir"
# mv ./build/distributions/io.gitpod.toolbox.gateway-0.0.1-dev.zip "$tarDir/io.gitpod.toolbox.gateway-0.0.1-dev.zip"
# echo "GITPOD_PLUGIN_ZIP=$tarDir/io.gitpod.toolbox.gateway-0.0.1-dev.zip" >> /tmp/__gh_output.txt
# # unzip ./build/distributions/io.gitpod.toolbox.gateway-0.0.1-dev.zip -d ./build
2 changes: 1 addition & 1 deletion components/ide/jetbrains/toolbox/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pluginVersion=0.0.1
pluginVersion=
environmentName=latest
supervisorApiProjectPath=../../../supervisor-api/java
gitpodPublicApiProjectPath=../../../public-api/java
12 changes: 8 additions & 4 deletions components/ide/jetbrains/toolbox/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
[versions]
gateway = "2.6.0.34606"
toolbox-plugin-api = "0.2"
kotlin = "2.0.10"
coroutines = "1.7.3"
serialization = "1.5.0"
okhttp = "4.10.0"
slf4j = "2.0.3"
dependency-license-report = "2.5"
marketplace-client = "2.0.38"
gradle-wrapper = "0.14.0"

[libraries]
kotlin-stdlib = { module = "com.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
gateway-api = { module = "com.jetbrains.toolbox.gateway:gateway-api", version.ref = "gateway" }
toolbox-core-api = { module = "com.jetbrains.toolbox:core-api", version.ref = "toolbox-plugin-api" }
toolbox-ui-api = { module = "com.jetbrains.toolbox:ui-api", version.ref = "toolbox-plugin-api" }
toolbox-remote-dev-api = { module = "com.jetbrains.toolbox:remote-dev-api", version.ref = "toolbox-plugin-api" }
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
Expand All @@ -21,9 +23,11 @@ slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
marketplace-client = { module = "org.jetbrains.intellij:plugin-repository-rest-client", version.ref = "marketplace-client" }

[bundles]
serialization = [ "serialization-core", "serialization-json", "serialization-json-okio" ]
serialization = [ "serialization-core", "serialization-json" ]
toolbox-plugin-api = [ "toolbox-core-api", "toolbox-ui-api", "toolbox-remote-dev-api" ]

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
dependency-license-report = { id = "com.github.jk1.dependency-license-report", version.ref = "dependency-license-report" }
gradle-wrapper = { id = "me.filippov.gradle.jvm.wrapper", version.ref = "gradle-wrapper" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions components/ide/jetbrains/toolbox/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright (c) 2024 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License.AGPL.txt in the project root for license information.

rootProject.name = "gitpod-toolbox-gateway"

include(":supervisor-api")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package io.gitpod.toolbox.auth

import com.connectrpc.Code
import com.connectrpc.ConnectException
import com.jetbrains.toolbox.gateway.auth.*
import com.jetbrains.toolbox.api.core.auth.*
import io.gitpod.publicapi.experimental.v1.UserServiceClient
import io.gitpod.toolbox.service.GitpodPublicApiManager
import io.gitpod.toolbox.service.Utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

package io.gitpod.toolbox.auth

import com.jetbrains.toolbox.gateway.ui.*
import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon
import com.jetbrains.toolbox.api.ui.actions.ActionDescription
import com.jetbrains.toolbox.api.ui.components.LinkField
import com.jetbrains.toolbox.api.ui.components.TextField
import com.jetbrains.toolbox.api.ui.components.UiField
import com.jetbrains.toolbox.api.ui.components.ValidationResult
import io.gitpod.toolbox.components.AbstractUiPage
import io.gitpod.toolbox.components.GitpodIconColored
import io.gitpod.toolbox.components.GitpodIcon
import io.gitpod.toolbox.components.SimpleButton
import io.gitpod.toolbox.service.Utils

Expand All @@ -25,8 +30,9 @@ class GitpodLoginPage(private val authManager: GitpodAuthManager) : AbstractUiPa
return mutableListOf(hostField, LinkField("Learn more", "https://gitpod.io/docs"))
}

override fun getActionButtons(): MutableList<ActionDescription> {
return mutableListOf(SimpleButton("Login") action@{

override fun getActionButtons(): List<ActionDescription> {
return listOf(SimpleButton("Login") action@{
val host = getFieldValue<String>(hostField) ?: return@action
val url = authManager.getOAuthLoginUrl(host)
Utils.openUrl(url)
Expand All @@ -37,7 +43,7 @@ class GitpodLoginPage(private val authManager: GitpodAuthManager) : AbstractUiPa

override fun getDescription() = "Always ready to code."

override fun getSvgIcon(): ByteArray {
return GitpodIconColored()
override fun getSvgIcon(): SvgIcon {
return GitpodIcon()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

package io.gitpod.toolbox.components

import com.jetbrains.toolbox.gateway.ui.UiField
import com.jetbrains.toolbox.gateway.ui.UiPage
import com.jetbrains.toolbox.api.ui.components.UiField
import com.jetbrains.toolbox.api.ui.components.UiPage

abstract class AbstractUiPage : UiPage {
private var stateAccessor: UiPage.UiFieldStateAccessor? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package io.gitpod.toolbox.components

import com.jetbrains.toolbox.gateway.ui.RunnableActionDescription
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription

open class SimpleButton(private val title: String, private val action: () -> Unit = {}): RunnableActionDescription {
override fun getLabel(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

package io.gitpod.toolbox.components

import com.jetbrains.toolbox.api.core.ui.icons.SvgIcon
import io.gitpod.toolbox.gateway.GitpodGatewayExtension

@Suppress("FunctionName")
fun GitpodIcon(): ByteArray {
return GitpodGatewayExtension::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf()
fun GitpodIconGray(): SvgIcon {
return SvgIcon(GitpodGatewayExtension::class.java.getResourceAsStream("/icon-gray.svg")?.readAllBytes() ?: byteArrayOf())
}

@Suppress("FunctionName")
fun GitpodIconColored(): ByteArray {
return GitpodGatewayExtension::class.java.getResourceAsStream("/icon-colored.svg")?.readAllBytes() ?: byteArrayOf()
fun GitpodIcon(): SvgIcon {
return SvgIcon(GitpodGatewayExtension::class.java.getResourceAsStream("/icon.svg")?.readAllBytes() ?: byteArrayOf())
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

package io.gitpod.toolbox.gateway

import com.jetbrains.toolbox.gateway.GatewayExtension
import com.jetbrains.toolbox.gateway.RemoteEnvironmentConsumer
import com.jetbrains.toolbox.gateway.RemoteProvider
import com.jetbrains.toolbox.gateway.ToolboxServiceLocator
import com.jetbrains.toolbox.api.core.ServiceLocator
import com.jetbrains.toolbox.api.remoteDev.RemoteDevExtension
import com.jetbrains.toolbox.api.remoteDev.RemoteEnvironmentConsumer
import com.jetbrains.toolbox.api.remoteDev.RemoteProvider
import io.gitpod.toolbox.service.Utils

class GitpodGatewayExtension : GatewayExtension {
override fun createRemoteProviderPluginInstance(serviceLocator: ToolboxServiceLocator): RemoteProvider {
class GitpodGatewayExtension : RemoteDevExtension {
override fun createRemoteProviderPluginInstance(serviceLocator: ServiceLocator): RemoteProvider {
Utils.initialize(serviceLocator)
return GitpodRemoteProvider(serviceLocator.getService(RemoteEnvironmentConsumer::class.java))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

package io.gitpod.toolbox.gateway

import com.jetbrains.toolbox.gateway.AbstractRemoteProviderEnvironment
import com.jetbrains.toolbox.gateway.EnvironmentVisibilityState
import com.jetbrains.toolbox.gateway.environments.EnvironmentContentsView
import com.jetbrains.toolbox.gateway.states.EnvironmentStateConsumer
import com.jetbrains.toolbox.gateway.states.StandardRemoteEnvironmentState
import com.jetbrains.toolbox.gateway.ui.ActionDescription
import com.jetbrains.toolbox.gateway.ui.ObservableList
import com.jetbrains.toolbox.gateway.ui.ObservablePropertiesFactory
import com.jetbrains.toolbox.api.remoteDev.AbstractRemoteProviderEnvironment
import com.jetbrains.toolbox.api.remoteDev.EnvironmentVisibilityState
import com.jetbrains.toolbox.api.remoteDev.environments.EnvironmentContentsView
import com.jetbrains.toolbox.api.remoteDev.states.CustomRemoteEnvironmentState
import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateConsumer
import com.jetbrains.toolbox.api.remoteDev.states.EnvironmentStateIcons
import com.jetbrains.toolbox.api.remoteDev.states.StandardRemoteEnvironmentState
import com.jetbrains.toolbox.api.ui.actions.ActionDescription
import com.jetbrains.toolbox.api.ui.observables.ObservableList
import com.jetbrains.toolbox.api.ui.observables.ObservablePropertiesFactory
import io.gitpod.publicapi.experimental.v1.Workspaces.WorkspaceInstanceStatus
import io.gitpod.toolbox.auth.GitpodAuthManager
import io.gitpod.toolbox.service.ConnectParams
Expand Down Expand Up @@ -100,17 +102,16 @@ private class WorkspaceEnvState(val phase: WorkspaceInstanceStatus.Phase) {

companion object {
val phaseToStateMap = mapOf(
WorkspaceInstanceStatus.Phase.PHASE_UNSPECIFIED to StandardRemoteEnvironmentState.Unreachable,
WorkspaceInstanceStatus.Phase.PHASE_PREPARING to StandardRemoteEnvironmentState.Initializing,
WorkspaceInstanceStatus.Phase.PHASE_IMAGEBUILD to StandardRemoteEnvironmentState.Initializing,
WorkspaceInstanceStatus.Phase.PHASE_PENDING to StandardRemoteEnvironmentState.Initializing,
WorkspaceInstanceStatus.Phase.PHASE_CREATING to StandardRemoteEnvironmentState.Initializing,
WorkspaceInstanceStatus.Phase.PHASE_INITIALIZING to StandardRemoteEnvironmentState.Initializing,
WorkspaceInstanceStatus.Phase.PHASE_RUNNING to StandardRemoteEnvironmentState.Active,
WorkspaceInstanceStatus.Phase.PHASE_UNSPECIFIED to CustomRemoteEnvironmentState("Unknown", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Inactive), false, EnvironmentStateIcons.Error),
WorkspaceInstanceStatus.Phase.PHASE_PREPARING to CustomRemoteEnvironmentState("Preparing", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Initializing), false, EnvironmentStateIcons.Connecting),
WorkspaceInstanceStatus.Phase.PHASE_IMAGEBUILD to CustomRemoteEnvironmentState("Building", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Initializing), false, EnvironmentStateIcons.Connecting),
WorkspaceInstanceStatus.Phase.PHASE_PENDING to CustomRemoteEnvironmentState("Initializing", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Initializing), false, EnvironmentStateIcons.Connecting),
WorkspaceInstanceStatus.Phase.PHASE_CREATING to CustomRemoteEnvironmentState("Creating", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Initializing), false, EnvironmentStateIcons.Connecting),
WorkspaceInstanceStatus.Phase.PHASE_INITIALIZING to CustomRemoteEnvironmentState("Initializing", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Initializing), false, EnvironmentStateIcons.Connecting),
WorkspaceInstanceStatus.Phase.PHASE_RUNNING to CustomRemoteEnvironmentState("Running", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Active), true, EnvironmentStateIcons.Active),
WorkspaceInstanceStatus.Phase.PHASE_INTERRUPTED to StandardRemoteEnvironmentState.Error,
WorkspaceInstanceStatus.Phase.PHASE_STOPPING to StandardRemoteEnvironmentState.Unreachable,
WorkspaceInstanceStatus.Phase.PHASE_STOPPED to StandardRemoteEnvironmentState.Hibernated,
WorkspaceInstanceStatus.Phase.PHASE_STOPPING to CustomRemoteEnvironmentState("Stopping", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Hibernating), false, EnvironmentStateIcons.Connecting),
WorkspaceInstanceStatus.Phase.PHASE_STOPPED to CustomRemoteEnvironmentState("Stopped", Utils.environmentStateColorPalette.getColor(StandardRemoteEnvironmentState.Hibernated), false, EnvironmentStateIcons.Hibernated),
)
}
// TODO(hw): add customized state
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

package io.gitpod.toolbox.gateway

import com.jetbrains.toolbox.gateway.environments.CachedIdeStub
import com.jetbrains.toolbox.gateway.environments.CachedProjectStub
import com.jetbrains.toolbox.gateway.environments.ManualEnvironmentContentsView
import com.jetbrains.toolbox.gateway.environments.SshEnvironmentContentsView
import com.jetbrains.toolbox.gateway.ssh.SshConnectionInfo
import com.jetbrains.toolbox.api.remoteDev.environments.CachedIdeStub
import com.jetbrains.toolbox.api.remoteDev.environments.CachedProjectStub
import com.jetbrains.toolbox.api.remoteDev.environments.ManualEnvironmentContentsView
import com.jetbrains.toolbox.api.remoteDev.environments.SshEnvironmentContentsView
import com.jetbrains.toolbox.api.remoteDev.ssh.SshConnectionInfo
import io.gitpod.publicapi.experimental.v1.Workspaces.WorkspaceInstanceStatus
import io.gitpod.toolbox.service.*
import io.gitpod.toolbox.utils.GitpodLogger
import java.util.concurrent.CompletableFuture

class GitpodRemoteEnvironmentContentsView(
Expand All @@ -34,7 +33,6 @@ class GitpodRemoteEnvironmentContentsView(
})

private val connectionInfo = CompletableFuture.supplyAsync {
GitpodLogger.info("===============connectionInfo ${connectParams.uniqueID}")
val (connInfo, cancel) = provider.connect()
this.cancel = cancel
connInfo
Expand Down
Loading

0 comments on commit d7b680a

Please sign in to comment.