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 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions .idea/gradle.xml

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

4 changes: 3 additions & 1 deletion .idea/misc.xml

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

8 changes: 8 additions & 0 deletions components/ide/jetbrains/toolbox/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf
6 changes: 6 additions & 0 deletions components/ide/jetbrains/toolbox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Gradle
.gradle
build

# IntelliJ IDEA
.idea
17 changes: 17 additions & 0 deletions components/ide/jetbrains/toolbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Gitpod Toolbox Plugin

To load plugin into the provided Toolbox App, run `./gradlew build copyPlugin`

or put files in the following directory:

* Windows: `%LocalAppData%/JetBrains/Toolbox/cache/plugins/plugin-id`
* macOS: `~/Library/Caches/JetBrains/Toolbox/plugins/plugin-id`
* Linux: `~/.local/share/JetBrains/Toolbox/plugins/plugin-id`


## How to Develop

- Open the Toolbox App in debug mode
```bash
TOOLBOX_DEV_DEBUG_SUSPEND=true && open /Applications/JetBrains\ Toolbox.app
```
201 changes: 201 additions & 0 deletions components/ide/jetbrains/toolbox/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
// 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.

import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
import com.github.jk1.license.render.JsonReportRenderer
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
import org.jetbrains.intellij.pluginRepository.model.LicenseUrl
import org.jetbrains.intellij.pluginRepository.model.ProductFamily
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
import java.nio.file.Path
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"
}

buildscript {
dependencies {
classpath(libs.marketplace.client)
}
}

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

dependencies {
implementation(project(":supervisor-api"))
implementation(project(":gitpod-publicapi"))

// com.connectrpc https://mvnrepository.com/artifact/com.connectrpc
// connect rpc dependencies
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.connectrpc:connect-kotlin-okhttp:0.6.0")
implementation("com.connectrpc:connect-kotlin:0.6.0")
// Java specific dependencies.
implementation("com.connectrpc:connect-kotlin-google-java-ext:0.6.0")
implementation("com.google.protobuf:protobuf-java:4.27.2")
// WebSocket
compileOnly("javax.websocket:javax.websocket-api:1.1")
compileOnly("org.eclipse.jetty.websocket:websocket-api:9.4.54.v20240208")
implementation("org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.54.v20240208")
// RD-Core https://mvnrepository.com/artifact/com.jetbrains.rd/rd-core
implementation("com.jetbrains.rd:rd-core:2024.1.1")

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"

tasks.shadowJar {
archiveBaseName.set(pluginId)
archiveVersion.set(pluginVersion)

val excludedGroups = listOf(
"com.jetbrains.toolbox.gateway",
"com.jetbrains",
"org.jetbrains",
"com.squareup.okhttp3",
"org.slf4j",
"org.jetbrains.intellij",
"com.squareup.okio",
"kotlin."
)

val includeGroups = listOf(
"com.jetbrains.rd"
)

dependencies {
exclude {
excludedGroups.any { group ->
if (includeGroups.any { includeGroup -> it.name.startsWith(includeGroup) }) {
return@any false
}
it.name.startsWith(group)
}
}
}
}

licenseReport {
renderers = arrayOf(JsonReportRenderer("dependencies.json"))
filters = arrayOf(ExcludeTransitiveDependenciesFilter())
}

tasks.compileKotlin {
kotlinOptions.freeCompilerArgs += listOf(
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
)
}

val restartToolbox by tasks.creating {
group = "01.Gitpod"
description = "Restarts the JetBrains Toolbox app."

doLast {
when {
SystemInfoRt.isMac -> {
exec {
commandLine("sh", "-c", "pkill -f 'JetBrains Toolbox' || true")
}
Thread.sleep(3000)
exec {
commandLine("sh", "-c", "echo debugClean > ~/Library/Logs/JetBrains/Toolbox/toolbox.log")
}
exec {
// environment("TOOLBOX_DEV_DEBUG_SUSPEND", "true")
commandLine("open", "/Applications/JetBrains Toolbox.app")
}
}

else -> {
println("restart Toolbox to make plugin works.")
}
}
}
}

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

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

val userHome = System.getProperty("user.home").let { Path.of(it) }
val toolboxCachesDir = when {
SystemInfoRt.isWindows -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
// currently this is the location that TBA uses on Linux
SystemInfoRt.isLinux -> System.getenv("XDG_DATA_HOME")?.let { Path.of(it) } ?: (userHome / ".local" / "share")
SystemInfoRt.isMac -> userHome / "Library" / "Caches"
else -> error("Unknown os")
} / "JetBrains" / "Toolbox"

val pluginsDir = when {
SystemInfoRt.isWindows -> toolboxCachesDir / "cache"
SystemInfoRt.isLinux || SystemInfoRt.isMac -> toolboxCachesDir
else -> error("Unknown os")
} / "plugins"

val targetDir = pluginsDir / pluginId

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

into(targetDir)

finalizedBy(restartToolbox)
}

val pluginZip by tasks.creating(Zip::class) {
dependsOn(tasks.named("shadowJar"))
from(tasks.named("shadowJar").get().outputs.files)

from("src/main/resources") {
include("extension.json")
include("dependencies.json")
}
from("src/main/resources") {
include("icon.svg")
rename("icon.svg", "pluginIcon.svg")
}
archiveBaseName.set("$pluginId-$pluginVersion")
}

val uploadPlugin by tasks.creating {
dependsOn(pluginZip)

doLast {
val token = System.getenv("JB_MARKETPLACE_PUBLISH_TOKEN")
val instance = PluginRepositoryFactory.create("https://plugins.jetbrains.com", token)

// first upload
// instance.uploader.uploadNewPlugin(
// pluginZip.outputs.files.singleFile,
// listOf("toolbox", "gateway", "gitpod"),
// LicenseUrl.GNU_LESSER,
// ProductFamily.TOOLBOX,
// "Gitpod",
// "dev"
// )

// subsequent updates
// instance.uploader.upload(pluginId, pluginZip.outputs.files.singleFile)
}
}
4 changes: 4 additions & 0 deletions components/ide/jetbrains/toolbox/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pluginVersion=0.0.1
environmentName=latest
supervisorApiProjectPath=../../../supervisor-api/java
gitpodPublicApiProjectPath=../../../public-api/java
30 changes: 30 additions & 0 deletions components/ide/jetbrains/toolbox/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[versions]
gateway = "2.5.0.32871"
#gateway = "2.4.0.31544"
kotlin = "1.9.0"
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"

[libraries]
kotlin-stdlib = { module = "com.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
gateway-api = { module = "com.jetbrains.toolbox.gateway:gateway-api", version.ref = "gateway" }
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" }
serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "serialization" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
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" ]

[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" }
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading