Skip to content

Commit 7151981

Browse files
committed
import code from coder/jetbrains-coder
1 parent 4fe83ce commit 7151981

File tree

173 files changed

+7972
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+7972
-270
lines changed

build.gradle.kts

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ plugins {
1111
alias(libs.plugins.serialization)
1212
`java-library`
1313
alias(libs.plugins.dependency.license.report)
14+
alias(libs.plugins.ksp)
1415
alias(libs.plugins.gradle.wrapper)
1516
}
1617

@@ -37,8 +38,17 @@ jvmWrapper {
3738

3839
dependencies {
3940
compileOnly(libs.bundles.toolbox.plugin.api)
41+
implementation(libs.slf4j)
42+
implementation(libs.tinylog)
4043
implementation(libs.bundles.serialization)
4144
implementation(libs.coroutines.core)
45+
implementation(libs.okhttp)
46+
implementation(libs.exec)
47+
implementation(libs.moshi)
48+
ksp(libs.moshi.codegen)
49+
implementation(libs.retrofit)
50+
implementation(libs.retrofit.moshi)
51+
testImplementation(kotlin("test"))
4252
}
4353

4454
licenseReport {
@@ -52,7 +62,11 @@ tasks.compileKotlin {
5262
compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
5363
}
5464

55-
val pluginId = "com.jetbrains.toolbox.sample"
65+
tasks.test {
66+
useJUnitPlatform()
67+
}
68+
69+
val pluginId = "com.coder.toolbox"
5670
val pluginVersion = "0.0.1"
5771

5872
val assemblePlugin by tasks.registering(Jar::class) {
@@ -63,6 +77,38 @@ val assemblePlugin by tasks.registering(Jar::class) {
6377
val copyPlugin by tasks.creating(Sync::class.java) {
6478
dependsOn(assemblePlugin)
6579

80+
from(assemblePlugin.get().outputs.files)
81+
from("src/main/resources") {
82+
include("extension.json")
83+
include("dependencies.json")
84+
include("icon.svg")
85+
}
86+
87+
// Copy dependencies, excluding those provided by Toolbox.
88+
from(
89+
configurations.compileClasspath.map { configuration ->
90+
configuration.files.filterNot { file ->
91+
listOf(
92+
"kotlin",
93+
"remote-dev-api",
94+
"core-api",
95+
"ui-api",
96+
"annotations",
97+
).any { file.name.contains(it) }
98+
}
99+
},
100+
)
101+
102+
into(getPluginInstallDir())
103+
}
104+
105+
tasks.register("cleanAll", Delete::class.java) {
106+
dependsOn(tasks.clean)
107+
delete(getPluginInstallDir())
108+
delete()
109+
}
110+
111+
private fun getPluginInstallDir(): Path {
66112
val userHome = System.getProperty("user.home").let { Path.of(it) }
67113
val toolboxCachesDir = when {
68114
SystemInfoRt.isWindows -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
@@ -78,18 +124,7 @@ val copyPlugin by tasks.creating(Sync::class.java) {
78124
else -> error("Unknown os")
79125
} / "plugins"
80126

81-
val targetDir = pluginsDir / pluginId
82-
83-
from(assemblePlugin.get().outputs.files)
84-
85-
from("src/main/resources") {
86-
include("extension.json")
87-
include("dependencies.json")
88-
include("icon.svg")
89-
}
90-
91-
into(targetDir)
92-
127+
return pluginsDir / pluginId
93128
}
94129

95130
val pluginZip by tasks.creating(Zip::class) {
@@ -119,4 +154,13 @@ val uploadPlugin by tasks.creating {
119154
// subsequent updates
120155
instance.uploader.upload(pluginId, pluginZip.outputs.files.singleFile)
121156
}
122-
}
157+
}
158+
159+
// For use with kotlin-language-server.
160+
tasks.register("classpath") {
161+
doFirst {
162+
File("classpath").writeText(
163+
sourceSets["main"].runtimeClasspath.asPath
164+
)
165+
}
166+
}

gradle/libs.versions.toml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ toolbox-plugin-api = "0.6.2.6.0.37447"
33
kotlin = "2.0.10"
44
coroutines = "1.7.3"
55
serialization = "1.5.0"
6+
okhttp = "4.10.0"
7+
slf4j = "2.0.3"
8+
tinylog = "2.7.0"
69
dependency-license-report = "2.5"
710
marketplace-client = "2.0.38"
811
gradle-wrapper = "0.14.0"
9-
12+
exec = "1.12"
13+
moshi = "1.15.1"
14+
ksp = "2.0.10-1.0.24"
15+
retrofit = "2.8.2"
1016

1117
[libraries]
1218
toolbox-core-api = { module = "com.jetbrains.toolbox:core-api", version.ref = "toolbox-plugin-api" }
@@ -15,15 +21,25 @@ toolbox-remote-dev-api = { module = "com.jetbrains.toolbox:remote-dev-api", vers
1521
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
1622
serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
1723
serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
24+
serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "serialization" }
25+
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
26+
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
27+
tinylog = {module = "org.tinylog:slf4j-tinylog", version.ref = "tinylog"}
28+
exec = { module = "org.zeroturnaround:zt-exec", version.ref = "exec" }
29+
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi"}
30+
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi"}
31+
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit"}
32+
retrofit-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit"}
1833

1934
marketplace-client = { module = "org.jetbrains.intellij:plugin-repository-rest-client", version.ref = "marketplace-client" }
2035

2136
[bundles]
22-
serialization = [ "serialization-core", "serialization-json" ]
37+
serialization = [ "serialization-core", "serialization-json", "serialization-json-okio" ]
2338
toolbox-plugin-api = [ "toolbox-core-api", "toolbox-ui-api", "toolbox-remote-dev-api" ]
2439

2540
[plugins]
2641
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
2742
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
2843
dependency-license-report = { id = "com.github.jk1.dependency-license-report", version.ref = "dependency-license-report" }
29-
gradle-wrapper = { id = "me.filippov.gradle.jvm.wrapper", version.ref = "gradle-wrapper" }
44+
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp"}
45+
gradle-wrapper = { id = "me.filippov.gradle.jvm.wrapper", version.ref = "gradle-wrapper" }

src/main/kotlin/SampleEnvironmentContentsView.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/kotlin/SampleRemoteDevExtension.kt

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/main/kotlin/SampleRemoteEnvironment.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/main/kotlin/SampleRemoteProvider.kt

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/main/kotlin/await.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.coder.toolbox
2+
3+
import com.jetbrains.toolbox.api.core.PluginSecretStore
4+
import com.jetbrains.toolbox.api.core.PluginSettingsStore
5+
import com.jetbrains.toolbox.api.core.ServiceLocator
6+
import com.jetbrains.toolbox.api.remoteDev.RemoteDevExtension
7+
import com.jetbrains.toolbox.api.remoteDev.RemoteEnvironmentConsumer
8+
import com.jetbrains.toolbox.api.remoteDev.RemoteProvider
9+
import com.jetbrains.toolbox.api.ui.ToolboxUi
10+
import kotlinx.coroutines.CoroutineScope
11+
import okhttp3.OkHttpClient
12+
13+
/**
14+
* Entry point into the extension.
15+
*/
16+
class CoderGatewayExtension : RemoteDevExtension {
17+
// All services must be passed in here and threaded as necessary.
18+
override fun createRemoteProviderPluginInstance(serviceLocator: ServiceLocator): RemoteProvider {
19+
return CoderRemoteProvider(
20+
OkHttpClient(),
21+
serviceLocator.getService(RemoteEnvironmentConsumer::class.java),
22+
serviceLocator.getService(CoroutineScope::class.java),
23+
serviceLocator.getService(ToolboxUi::class.java),
24+
serviceLocator.getService(PluginSettingsStore::class.java),
25+
serviceLocator.getService(PluginSecretStore::class.java),
26+
)
27+
}
28+
}

0 commit comments

Comments
 (0)