Skip to content

Commit 26ccab4

Browse files
committed
Add support for 2022.3 JetBrains IDEs
1 parent d9dfaee commit 26ccab4

File tree

7 files changed

+67
-43
lines changed

7 files changed

+67
-43
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ dependencies {
6767
// Read more: https://github.com/JetBrains/gradle-intellij-plugin
6868
intellij {
6969
pluginName.set(properties("pluginName"))
70-
version.set(properties("platformVersion"))
70+
if (File(properties("localPath")).let { it.exists() && it.isDirectory }) {
71+
localPath.set(properties("localPath"))
72+
} else {
73+
version.set(properties("platformVersion"))
74+
}
7175
type.set(properties("platformType"))
7276
instrumentCode.set(false)
7377
downloadSources.set(properties("platformDownloadSources").toBoolean())
@@ -115,6 +119,7 @@ tasks {
115119
}
116120

117121
runPluginVerifier {
122+
enabled = false // TODO: Re-enable it when there's a 2022.3 ide version released.
118123
ideVersions.set(properties("pluginVerifierIdeVersions").split(',').map(String::trim).filter(String::isNotEmpty))
119124
}
120125
}
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
22
# for insight into build numbers and IntelliJ Platform versions.
3-
pluginSinceBuild=222
4-
pluginUntilBuild=222.*
3+
pluginSinceBuild=223
4+
pluginUntilBuild=223.*
55
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
66
# See https://jb.gg/intellij-platform-builds-list for available build versions.
7-
pluginVerifierIdeVersions=2022.2
7+
pluginVerifierIdeVersions=2022.3
88
# Version from "com.jetbrains.intellij.idea" which can be found at https://www.jetbrains.com/intellij-repository/snapshots
9-
platformVersion=222.3739-EAP-CANDIDATE-SNAPSHOT
9+
platformVersion=223.1192-EAP-CANDIDATE-SNAPSHOT
10+
# If you want to try, during development, a snapshot that you need to download because it's not available at https://www.jetbrains.com/intellij-repository/snapshots, run the following command:
11+
# (cd /workspace && rm -rf ide-backend && wget https://download-cdn.jetbrains.com/idea/gateway/idea_tmp/ideaIU-223.2931.tar.gz && tar -xvf ideaIU-223.2931.tar.gz && rm ideaIU-223.2931.tar.gz && mv idea-IU-223.2931 ide-backend)
12+
localPath=/workspace/ide-backend

components/ide/jetbrains/backend-plugin/launch-dev-server.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
set -e
77
set -o pipefail
88

9-
TEST_BACKEND_DIR=/workspace/ide-backend
9+
TEST_BACKEND_DIR=$(cat gradle-latest.properties | grep localPath= | sed 's/localPath=//')
1010
if [ ! -d "$TEST_BACKEND_DIR" ]; then
1111
mkdir -p $TEST_BACKEND_DIR
12-
cp -r /ide-desktop/backend/* $TEST_BACKEND_DIR
12+
SNAPSHOT_VERSION=$(cat gradle-latest.properties | grep platformVersion= | sed 's/platformVersion=//')
13+
(cd $TEST_BACKEND_DIR && wget https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/${SNAPSHOT_VERSION}/ideaIU-${SNAPSHOT_VERSION}.zip && unzip ideaIU-${SNAPSHOT_VERSION}.zip && rm ideaIU-${SNAPSHOT_VERSION}.zip)
1314
fi
1415

1516
TEST_PLUGINS_DIR="$TEST_BACKEND_DIR/plugins"
@@ -40,7 +41,7 @@ export IJ_HOST_SYSTEM_BASE_DIR=/workspace/.cache/JetBrains
4041
export CWM_HOST_STATUS_OVER_HTTP_TOKEN=gitpod
4142

4243
# Build and move idea-cli, then overwrite environment variables initially defined by `components/ide/jetbrains/image/leeway.Dockerfile`
43-
IDEA_CLI_DEV_PATH=/ide-desktop/bin/idea-cli-dev
44+
IDEA_CLI_DEV_PATH=$TEST_BACKEND_DIR/bin/idea-cli-dev
4445
(cd ../cli && go build -o $IDEA_CLI_DEV_PATH)
4546
export EDITOR="$IDEA_CLI_DEV_PATH open"
4647
export VISUAL="$EDITOR"

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodCLIService.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ import io.netty.channel.ChannelHandlerContext
2525
import io.netty.handler.codec.http.FullHttpRequest
2626
import io.netty.handler.codec.http.QueryStringDecoder
2727
import io.prometheus.client.exporter.common.TextFormat
28+
import kotlinx.coroutines.Dispatchers
29+
import kotlinx.coroutines.GlobalScope
30+
import kotlinx.coroutines.launch
31+
import kotlinx.coroutines.withContext
2832
import org.jetbrains.ide.RestService
2933
import org.jetbrains.io.response
3034
import java.io.OutputStreamWriter
3135
import java.nio.file.InvalidPathException
3236
import java.nio.file.Path
3337

34-
@Suppress("UnstableApiUsage")
38+
@Suppress("UnstableApiUsage", "OPT_IN_USAGE")
3539
class GitpodCLIService : RestService() {
3640

3741
private val manager = service<GitpodManager>()
@@ -65,7 +69,11 @@ class GitpodCLIService : RestService() {
6569
val file = parseFilePath(fileStr) ?: return "invalid file"
6670
val shouldWait = getBooleanParameter("wait", urlDecoder)
6771
return withClient(request, context) {
68-
CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.get()
72+
GlobalScope.launch {
73+
withContext(Dispatchers.IO) {
74+
CommandLineProcessor.doOpenFileOrProject(file, shouldWait).future.get()
75+
}
76+
}
6977
}
7078
}
7179
if (operation == "preview") {

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/GitpodClientProjectSessionTracker.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package io.gitpod.jetbrains.remote
66

77
import com.intellij.codeWithMe.ClientId
88
import com.intellij.ide.BrowserUtil
9-
import com.intellij.idea.StartupUtil
9+
import com.intellij.idea.getServerFutureAsync
1010
import com.intellij.notification.NotificationAction
1111
import com.intellij.notification.NotificationType
1212
import com.intellij.openapi.Disposable
@@ -120,7 +120,7 @@ class GitpodClientProjectSessionTracker(
120120

121121
// Ignore ports that aren't actually used by the user (e.g. ports used internally by JetBrains IDEs)
122122
val backendPort = BuiltInServerManager.getInstance().waitForStart().port
123-
val serverPort = StartupUtil.getServerFuture().await().port
123+
val serverPort = getServerFutureAsync().await()?.port
124124
val ignorePorts = listOf(backendPort, serverPort, 5990)
125125
val portsStatus = hashMapOf<Int, PortsStatus>()
126126

components/ide/jetbrains/backend-plugin/src/main/kotlin/io/gitpod/jetbrains/remote/latest/GitpodPortForwardingService.kt

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import com.intellij.openapi.diagnostic.thisLogger
99
import com.intellij.openapi.project.Project
1010
import com.intellij.remoteDev.util.onTerminationOrNow
1111
import com.intellij.util.application
12-
import com.jetbrains.codeWithMe.model.RdPortType
12+
import com.jetbrains.rd.platform.codeWithMe.portForwarding.PortType
1313
import com.jetbrains.rd.platform.util.lifetime
1414
import com.jetbrains.rd.util.lifetime.LifetimeStatus
15-
import com.jetbrains.rdserver.portForwarding.ForwardedPortInfo
16-
import com.jetbrains.rdserver.portForwarding.PortForwardingManager
17-
import com.jetbrains.rdserver.portForwarding.remoteDev.PortEventsProcessor
15+
import com.jetbrains.rdserver.portForwarding.*
16+
import com.jetbrains.rdserver.portForwarding.remoteDev.ControllerPortsInformationProvider
1817
import io.gitpod.jetbrains.remote.GitpodManager
1918
import io.gitpod.jetbrains.remote.GitpodPortsService
2019
import io.gitpod.supervisor.api.Status
@@ -32,6 +31,7 @@ class GitpodPortForwardingService(private val project: Project) {
3231
}
3332

3433
private val portsService = service<GitpodPortsService>()
34+
private val controllerPortsInformationProvider = service<ControllerPortsInformationProvider>()
3535

3636
init { start() }
3737

@@ -85,44 +85,51 @@ class GitpodPortForwardingService(private val project: Project) {
8585
}
8686

8787
private fun updateForwardedPortsList(response: Status.PortsStatusResponse) {
88-
val portForwardingManager = PortForwardingManager.getInstance(project)
89-
val forwardedPortsList = portForwardingManager.getForwardedPortsWithLabel(FORWARDED_PORT_LABEL)
88+
val portForwardingManager = PortForwardingManager.getInstance()
89+
val forwardedPorts = portForwardingManager.getPortsWithLabel(FORWARDED_PORT_LABEL)
9090

9191
for (port in response.portsList) {
9292
val hostPort = port.localPort
9393
val isServed = port.served
94+
val existingForwardedPort = forwardedPorts.find { it.hostPortNumber == hostPort }
9495

95-
if (isServed && !forwardedPortsList.containsKey(hostPort)) {
96-
val portEventsProcessor = object : PortEventsProcessor {
97-
override fun onPortForwarded(hostPort: Int, clientPort: Int) {
98-
portsService.setForwardedPort(hostPort, clientPort)
99-
thisLogger().info("gitpod: Forwarded port $hostPort to client's port $clientPort.")
100-
}
96+
if (isServed && existingForwardedPort == null) {
97+
portForwardingManager.addPort(Port.ExposedPort(
98+
hostPort,
99+
PortIdentity.MutableNameAndDescription(port.name, port.description),
100+
setOf(FORWARDED_PORT_LABEL),
101+
Property(port.exposed.url),
102+
Property(PortVisibility.PrivatePort())
103+
))
101104

102-
override fun onPortForwardingEnded(hostPort: Int) {
103-
thisLogger().info("gitpod: Finished forwarding port $hostPort.")
105+
portForwardingManager.addPort(Port.ForwardedPort(
106+
hostPort,
107+
PortType.HTTP,
108+
PortIdentity.MutableNameAndDescription(port.name, port.description),
109+
setOf(FORWARDED_PORT_LABEL)
110+
))
111+
112+
// Note: The code below won't work because the addittion of a port takes some time in background, so it's
113+
// to early to try caching them at this moment.
114+
when (val clientPortState = controllerPortsInformationProvider.getForwardedClientPortState(hostPort)) {
115+
is ClientPortState.Assigned -> {
116+
thisLogger().warn("gitpod: Started forwarding host port $hostPort to client port ${clientPortState.clientPort}.")
117+
portsService.setForwardedPort(hostPort, clientPortState.clientPort)
104118
}
105-
106-
override fun onPortForwardingFailed(hostPort: Int, reason: String) {
107-
thisLogger().error("gitpod: Failed to forward port $hostPort: $reason")
119+
is ClientPortState.FailedToAssign -> {
120+
thisLogger().warn("gitpod: Detected that host port $hostPort failed to be assigned to a client port.")
121+
}
122+
else -> {
123+
thisLogger().warn("gitpod: Detected that host port $hostPort is not assigned to any client port.")
108124
}
109125
}
110-
111-
val portInfo = ForwardedPortInfo(
112-
hostPort,
113-
RdPortType.HTTP,
114-
FORWARDED_PORT_LABEL,
115-
emptyList(),
116-
portEventsProcessor
117-
)
118-
119-
portForwardingManager.forwardPort(portInfo)
120126
}
121127

122-
if (!isServed && forwardedPortsList.containsKey(hostPort)) {
123-
portForwardingManager.removePort(hostPort)
128+
if (!isServed && existingForwardedPort != null) {
129+
thisLogger().warn("hostPort $hostPort stopped being")
130+
portForwardingManager.removePort(existingForwardedPort)
124131
portsService.removeForwardedPort(hostPort)
125-
thisLogger().info("gitpod: Stopped forwarding port $hostPort.")
132+
thisLogger().warn("gitpod: Stopped forwarding port $hostPort.")
126133
}
127134
}
128135
}

components/ide/jetbrains/image/BUILD.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ packages:
5050
metadata:
5151
helm-component: workspace.desktopIdeImages.intellijLatest
5252
buildArgs:
53-
JETBRAINS_BACKEND_URL: "https://download.jetbrains.com/product?type=release,rc,eap&distribution=linux&code=IIU"
53+
JETBRAINS_BACKEND_URL: "https://download-cdn.jetbrains.com/idea/gateway/idea_tmp/ideaIU-223.2931.tar.gz"
5454
SUPERVISOR_IDE_CONFIG: supervisor-ide-config_intellij.json
5555
JETBRAINS_BACKEND_QUALIFIER: latest
5656
image:

0 commit comments

Comments
 (0)