Skip to content

Commit 62c1441

Browse files
committed
Make local easier to dev
1 parent 6561ef9 commit 62c1441

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

components/ide/jetbrains/gateway-plugin/build.gradle.kts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See License.AGPL.txt in the project root for license information.
44

55
import io.gitlab.arturbosch.detekt.Detekt
6+
import org.jetbrains.changelog.date
67
import org.jetbrains.changelog.markdownToHTML
78
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
89
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
@@ -36,6 +37,8 @@ if (environmentName.isNotBlank()) {
3637
pluginVersion += "-$environmentName"
3738
}
3839

40+
pluginVersion = pluginVersion.replace("{{LOCAL_VERSION}}", date("MMddhhmm") + "-local")
41+
3942
project(":") {
4043
kotlin {
4144
val excludedPackage = if (environmentName == "latest") "stable" else "latest"
@@ -176,3 +179,38 @@ tasks {
176179
}
177180
}
178181
}
182+
183+
tasks.register("installPlugin") {
184+
group = "gitpod"
185+
186+
println("Building plugin $pluginVersion")
187+
188+
dependsOn("buildPlugin")
189+
190+
doLast {
191+
val pluginTargetPath = "distributions/jetbrains-gateway-gitpod-plugin.zip"
192+
val pluginFile = layout.buildDirectory.file(pluginTargetPath).orNull?.asFile ?: {
193+
throw GradleException("Plugin file not found at $pluginTargetPath")
194+
}
195+
196+
// Example for macOS ~/Library/Application Support/JetBrains/JetBrainsGateway2024.3/plugins
197+
//
198+
// JB_GATEWAY_PLUGINS_DIR=/Users/hwen/Library/Application\ Support/JetBrains/JetBrainsGateway2024.3/plugins
199+
val gatewayPluginsDir = System.getenv("JB_GATEWAY_PLUGINS_DIR")
200+
if (gatewayPluginsDir.isNullOrEmpty()) {
201+
throw GradleException("Found no JB_GATEWAY_PLUGINS_DIR environment variable")
202+
}
203+
println("Copying plugin from $pluginFile to $gatewayPluginsDir")
204+
205+
copy {
206+
from(zipTree(pluginFile))
207+
into(file(gatewayPluginsDir))
208+
}
209+
210+
println("Plugin successfully copied to $gatewayPluginsDir")
211+
212+
exec {
213+
commandLine("sh", "-c", "pkill -f 'Gateway' || true")
214+
}
215+
}
216+
}

components/ide/jetbrains/gateway-plugin/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pluginName=gitpod-gateway
88
latestPluginName=Gitpod Gateway
99
pluginId=io.gitpod.jetbrains.gateway
1010
# It is overriden by CI during the build.
11-
pluginVersion=0.0.1
11+
pluginVersion={{LOCAL_VERSION}}
1212
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-type
1313
platformType=GW
1414
platformDownloadSources=true

components/ide/jetbrains/gateway-plugin/src/main/kotlin/io/gitpod/jetbrains/gateway/GitpodWorkspacesView.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ package io.gitpod.jetbrains.gateway
66

77
import com.intellij.icons.AllIcons
88
import com.intellij.ide.BrowserUtil
9+
import com.intellij.ide.plugins.PluginManagerCore
910
import com.intellij.openapi.CompositeDisposable
1011
import com.intellij.openapi.actionSystem.AnActionEvent
1112
import com.intellij.openapi.application.ApplicationManager
1213
import com.intellij.openapi.components.service
1314
import com.intellij.openapi.diagnostic.thisLogger
15+
import com.intellij.openapi.extensions.PluginId
1416
import com.intellij.openapi.project.DumbAwareAction
1517
import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenUIManager
1618
import com.intellij.remoteDev.util.onTerminationOrNow
@@ -106,10 +108,12 @@ class GitpodWorkspacesView(
106108
}
107109
}.visibleIf(loggedIn.not())
108110

111+
val pluginVersion = PluginManagerCore.getPlugin(PluginId.getId("io.gitpod.jetbrains.gateway"))?.version
112+
val pluginVersionLabel = if (pluginVersion?.contains("-local") == true) " (${pluginVersion})" else ""
109113
rowsRange {
110114
row {
111115
icon(GitpodIcons.Logo).gap(RightGap.SMALL)
112-
label("Gitpod").applyToComponent {
116+
label("Gitpod${pluginVersionLabel}").applyToComponent {
113117
this.font = JBFont.h3().asBold()
114118
}
115119
label("").resizableColumn().align(AlignX.FILL)

0 commit comments

Comments
 (0)