Skip to content

Commit 42440a0

Browse files
mustard-mhjeanp413
andcommitted
[JetBrains] try it out
Co-authored-by: Jean Pierre <[email protected]>
1 parent 3c9005d commit 42440a0

35 files changed

+2098
-0
lines changed

.idea/gradle.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Gradle
2+
.gradle
3+
build
4+
5+
# IntelliJ IDEA
6+
.idea
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Gitpod Toolbox Plugin
2+
3+
To load plugin into the provided Toolbox App, run `./gradlew build copyPlugin`
4+
5+
or put files in the following directory:
6+
7+
* Windows: `%LocalAppData%/JetBrains/Toolbox/cache/plugins/plugin-id`
8+
* macOS: `~/Library/Caches/JetBrains/Toolbox/plugins/plugin-id`
9+
* Linux: `~/.local/share/JetBrains/Toolbox/plugins/plugin-id`
10+
11+
12+
## How to Develop
13+
14+
- Open the Toolbox App in debug mode
15+
```bash
16+
TOOLBOX_DEV_DEBUG_SUSPEND=true && open /Applications/JetBrains\ Toolbox.app
17+
```
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// Copyright (c) 2024 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.
4+
5+
import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
6+
import com.github.jk1.license.render.JsonReportRenderer
7+
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
8+
import org.jetbrains.intellij.pluginRepository.model.LicenseUrl
9+
import org.jetbrains.intellij.pluginRepository.model.ProductFamily
10+
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
11+
import java.nio.file.Path
12+
import kotlin.io.path.div
13+
14+
plugins {
15+
alias(libs.plugins.kotlin)
16+
alias(libs.plugins.serialization)
17+
`java-library`
18+
alias(libs.plugins.dependency.license.report)
19+
id("com.github.johnrengelman.shadow") version "8.1.1"
20+
}
21+
22+
buildscript {
23+
dependencies {
24+
classpath(libs.marketplace.client)
25+
}
26+
}
27+
28+
repositories {
29+
mavenCentral()
30+
maven("https://packages.jetbrains.team/maven/p/tbx/gateway")
31+
}
32+
33+
dependencies {
34+
implementation(project(":supervisor-api"))
35+
implementation(project(":gitpod-publicapi"))
36+
37+
// com.connectrpc https://mvnrepository.com/artifact/com.connectrpc
38+
// connect rpc dependencies
39+
implementation("com.squareup.okhttp3:okhttp:4.12.0")
40+
implementation("com.connectrpc:connect-kotlin-okhttp:0.6.0")
41+
implementation("com.connectrpc:connect-kotlin:0.6.0")
42+
// Java specific dependencies.
43+
implementation("com.connectrpc:connect-kotlin-google-java-ext:0.6.0")
44+
implementation("com.google.protobuf:protobuf-java:4.27.2")
45+
// WebSocket
46+
compileOnly("javax.websocket:javax.websocket-api:1.1")
47+
compileOnly("org.eclipse.jetty.websocket:websocket-api:9.4.54.v20240208")
48+
implementation("org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.54.v20240208")
49+
// RD-Core https://mvnrepository.com/artifact/com.jetbrains.rd/rd-core
50+
implementation("com.jetbrains.rd:rd-core:2024.1.1")
51+
52+
implementation(libs.gateway.api)
53+
implementation(libs.slf4j)
54+
implementation(libs.bundles.serialization)
55+
implementation(libs.coroutines.core)
56+
implementation(libs.okhttp)
57+
}
58+
59+
60+
val pluginId = "io.gitpod.toolbox.gateway"
61+
val pluginVersion = "0.0.1-dev"
62+
63+
tasks.shadowJar {
64+
archiveBaseName.set(pluginId)
65+
archiveVersion.set(pluginVersion)
66+
67+
val excludedGroups = listOf(
68+
"com.jetbrains.toolbox.gateway",
69+
"com.jetbrains",
70+
"org.jetbrains",
71+
"com.squareup.okhttp3",
72+
"org.slf4j",
73+
"org.jetbrains.intellij",
74+
"com.squareup.okio",
75+
"kotlin."
76+
)
77+
78+
val includeGroups = listOf(
79+
"com.jetbrains.rd"
80+
)
81+
82+
dependencies {
83+
exclude {
84+
excludedGroups.any { group ->
85+
if (includeGroups.any { includeGroup -> it.name.startsWith(includeGroup) }) {
86+
return@any false
87+
}
88+
it.name.startsWith(group)
89+
}
90+
}
91+
}
92+
}
93+
94+
licenseReport {
95+
renderers = arrayOf(JsonReportRenderer("dependencies.json"))
96+
filters = arrayOf(ExcludeTransitiveDependenciesFilter())
97+
}
98+
99+
tasks.compileKotlin {
100+
kotlinOptions.freeCompilerArgs += listOf(
101+
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
102+
)
103+
}
104+
105+
val restartToolbox by tasks.creating {
106+
group = "01.Gitpod"
107+
description = "Restarts the JetBrains Toolbox app."
108+
109+
doLast {
110+
when {
111+
SystemInfoRt.isMac -> {
112+
exec {
113+
commandLine("sh", "-c", "pkill -f 'JetBrains Toolbox' || true")
114+
}
115+
Thread.sleep(3000)
116+
exec {
117+
commandLine("sh", "-c", "echo debugClean > ~/Library/Logs/JetBrains/Toolbox/toolbox.log")
118+
}
119+
exec {
120+
// environment("TOOLBOX_DEV_DEBUG_SUSPEND", "true")
121+
commandLine("open", "/Applications/JetBrains Toolbox.app")
122+
}
123+
}
124+
125+
else -> {
126+
println("restart Toolbox to make plugin works.")
127+
}
128+
}
129+
}
130+
}
131+
132+
val copyPlugin by tasks.creating(Sync::class.java) {
133+
group = "01.Gitpod"
134+
135+
dependsOn(tasks.named("shadowJar"))
136+
from(tasks.named("shadowJar").get().outputs.files)
137+
138+
val userHome = System.getProperty("user.home").let { Path.of(it) }
139+
val toolboxCachesDir = when {
140+
SystemInfoRt.isWindows -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
141+
// currently this is the location that TBA uses on Linux
142+
SystemInfoRt.isLinux -> System.getenv("XDG_DATA_HOME")?.let { Path.of(it) } ?: (userHome / ".local" / "share")
143+
SystemInfoRt.isMac -> userHome / "Library" / "Caches"
144+
else -> error("Unknown os")
145+
} / "JetBrains" / "Toolbox"
146+
147+
val pluginsDir = when {
148+
SystemInfoRt.isWindows -> toolboxCachesDir / "cache"
149+
SystemInfoRt.isLinux || SystemInfoRt.isMac -> toolboxCachesDir
150+
else -> error("Unknown os")
151+
} / "plugins"
152+
153+
val targetDir = pluginsDir / pluginId
154+
155+
from("src/main/resources") {
156+
include("extension.json")
157+
include("dependencies.json")
158+
include("icon.svg")
159+
}
160+
161+
into(targetDir)
162+
163+
finalizedBy(restartToolbox)
164+
}
165+
166+
val pluginZip by tasks.creating(Zip::class) {
167+
dependsOn(tasks.named("shadowJar"))
168+
from(tasks.named("shadowJar").get().outputs.files)
169+
170+
from("src/main/resources") {
171+
include("extension.json")
172+
include("dependencies.json")
173+
}
174+
from("src/main/resources") {
175+
include("icon.svg")
176+
rename("icon.svg", "pluginIcon.svg")
177+
}
178+
archiveBaseName.set("$pluginId-$pluginVersion")
179+
}
180+
181+
val uploadPlugin by tasks.creating {
182+
dependsOn(pluginZip)
183+
184+
doLast {
185+
val token = System.getenv("JB_MARKETPLACE_PUBLISH_TOKEN")
186+
val instance = PluginRepositoryFactory.create("https://plugins.jetbrains.com", token)
187+
188+
// first upload
189+
// instance.uploader.uploadNewPlugin(
190+
// pluginZip.outputs.files.singleFile,
191+
// listOf("toolbox", "gateway", "gitpod"),
192+
// LicenseUrl.GNU_LESSER,
193+
// ProductFamily.TOOLBOX,
194+
// "Gitpod",
195+
// "dev"
196+
// )
197+
198+
// subsequent updates
199+
// instance.uploader.upload(pluginId, pluginZip.outputs.files.singleFile)
200+
}
201+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pluginVersion=0.0.1
2+
environmentName=latest
3+
supervisorApiProjectPath=../../../supervisor-api/java
4+
gitpodPublicApiProjectPath=../../../public-api/java
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[versions]
2+
gateway = "2.5.0.32871"
3+
#gateway = "2.4.0.31544"
4+
kotlin = "1.9.0"
5+
coroutines = "1.7.3"
6+
serialization = "1.5.0"
7+
okhttp = "4.10.0"
8+
slf4j = "2.0.3"
9+
dependency-license-report = "2.5"
10+
marketplace-client = "2.0.38"
11+
12+
[libraries]
13+
kotlin-stdlib = { module = "com.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
14+
gateway-api = { module = "com.jetbrains.toolbox.gateway:gateway-api", version.ref = "gateway" }
15+
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
16+
serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
17+
serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
18+
serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "serialization" }
19+
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
20+
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
21+
22+
marketplace-client = { module = "org.jetbrains.intellij:plugin-repository-rest-client", version.ref = "marketplace-client" }
23+
24+
[bundles]
25+
serialization = [ "serialization-core", "serialization-json", "serialization-json-okio" ]
26+
27+
[plugins]
28+
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
29+
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
30+
dependency-license-report = { id = "com.github.jk1.dependency-license-report", version.ref = "dependency-license-report" }
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)