Skip to content

Commit dbf4a44

Browse files
committed
jb: configure SDK workaround
1 parent a87a1c8 commit dbf4a44

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2022 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+
package io.gitpod.jetbrains.remote
6+
7+
import com.intellij.openapi.diagnostic.thisLogger
8+
import com.intellij.openapi.project.Project
9+
import com.intellij.openapi.projectRoots.ProjectJdkTable
10+
import com.intellij.openapi.roots.ProjectRootManager
11+
import com.intellij.util.application
12+
13+
class GitpodProjectManager(
14+
private val project: Project
15+
) {
16+
17+
init {
18+
application.invokeLaterOnWriteThread {
19+
application.runWriteAction {
20+
configureSdk()
21+
}
22+
}
23+
}
24+
25+
/**
26+
* It is a workaround for https://youtrack.jetbrains.com/issue/GTW-88
27+
*/
28+
private fun configureSdk() {
29+
ProjectJdkTable.getInstance().preconfigure()
30+
val sdk = ProjectJdkTable.getInstance().allJdks.firstOrNull() ?: return
31+
val projectRootManager = ProjectRootManager.getInstance(project)
32+
if (projectRootManager.projectSdk != null) {
33+
return
34+
}
35+
projectRootManager.projectSdk = sdk
36+
thisLogger().warn("gitpod: SDK was auto preconfigured: $sdk")
37+
}
38+
}

components/ide/jetbrains/backend-plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<applicationService serviceImplementation="io.gitpod.jetbrains.remote.GitpodBranding"
2626
serviceInterface="com.intellij.remoteDev.customization.GatewayBranding"
2727
overrides="true" />
28+
<projectService serviceImplementation="io.gitpod.jetbrains.remote.GitpodProjectManager" preload="true"/>
2829
</extensions>
2930

3031
</idea-plugin>

0 commit comments

Comments
 (0)