Skip to content

Support for toolbox 2.6.0.38881 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 109 additions & 29 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.github.jk1.license.filter.ExcludeTransitiveDependenciesFilter
import com.github.jk1.license.render.JsonReportRenderer
import com.jetbrains.plugin.structure.toolbox.ToolboxMeta
import com.jetbrains.plugin.structure.toolbox.ToolboxPluginDescriptor
import org.jetbrains.intellij.pluginRepository.PluginRepositoryFactory
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.nio.file.Path
import kotlin.io.path.createDirectories
import kotlin.io.path.div
import kotlin.io.path.writeText

plugins {
alias(libs.plugins.kotlin)
Expand All @@ -14,23 +19,31 @@ plugins {
alias(libs.plugins.ksp)
alias(libs.plugins.gradle.wrapper)
alias(libs.plugins.changelog)
alias(libs.plugins.gettext)
}

buildscript {
dependencies {
classpath(libs.marketplace.client)
}
}

repositories {
mavenCentral()
maven("https://packages.jetbrains.team/maven/p/tbx/toolbox-api")
}

buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath(libs.marketplace.client)
classpath(libs.plugin.structure)
}
}

jvmWrapper {
unixJvmInstallDir = "jvm"
winJvmInstallDir = "jvm"
linuxAarch64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-linux-aarch64-b631.28.tar.gz"
linuxAarch64JvmUrl =
"https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-linux-aarch64-b631.28.tar.gz"
linuxX64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-linux-x64-b631.28.tar.gz"
macAarch64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-osx-aarch64-b631.28.tar.gz"
macX64JvmUrl = "https://cache-redirector.jetbrains.com/intellij-jbr/jbr_jcef-21.0.5-osx-x64-b631.28.tar.gz"
Expand All @@ -39,9 +52,9 @@ jvmWrapper {

dependencies {
compileOnly(libs.bundles.toolbox.plugin.api)
compileOnly(libs.bundles.serialization)
compileOnly(libs.coroutines.core)
implementation(libs.slf4j)
implementation(libs.bundles.serialization)
implementation(libs.coroutines.core)
implementation(libs.okhttp)
implementation(libs.exec)
implementation(libs.moshi)
Expand All @@ -51,12 +64,29 @@ dependencies {
testImplementation(kotlin("test"))
}

val pluginId = properties("group")
val pluginName = properties("name")
val pluginVersion = properties("version")
val extension = ExtensionJson(
id = properties("group"),
version = properties("version"),
meta = ExtensionJsonMeta(
name = "Coder Toolbox",
description = "Connects your JetBrains IDE to Coder workspaces",
vendor = "Coder",
url = "https://github.com/coder/coder-jetbrains-toolbox-plugin",
)
)

val extensionJsonFile = layout.buildDirectory.file("generated/extension.json")
val extensionJson by tasks.registering {
inputs.property("extension", extension.toString())

outputs.file(extensionJsonFile)
doLast {
generateExtensionJson(extension, extensionJsonFile.get().asFile.toPath())
}
}

changelog {
version.set(pluginVersion)
version.set(extension.version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to call plugin an extension from now on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP but indeed it is confusing me as well (especially when "extension" has a different meaning in the context of JetBrains plugins). It is the "nomenclature" used by JetBrains in the sample. I will refactor and simplify some of the things once I have the code working. Bear in mind that this is a wip for now :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably involve the JetBrains team. At least share the confusion wit them.

groups.set(emptyList())
title.set("Coder Toolbox Plugin Changelog")
}
Expand All @@ -76,15 +106,27 @@ tasks.test {
useJUnitPlatform()
}

tasks.jar {
archiveBaseName.set(extension.id)
dependsOn(extensionJson)
}

val assemblePlugin by tasks.registering(Jar::class) {
archiveBaseName.set(pluginId)
archiveBaseName.set(extension.id)
from(sourceSets.main.get().output)
}

val copyPlugin by tasks.creating(Sync::class.java) {
dependsOn(assemblePlugin)
fromCompileDependencies()
dependsOn(tasks.assemble)
// fromCompileDependencies()
from(tasks.jar)

from(extensionJsonFile)

from("src/main/resources") {
include("dependencies.json")
include("icon.svg")
}
into(getPluginInstallDir())
}

Expand Down Expand Up @@ -113,11 +155,21 @@ fun CopySpec.fromCompileDependencies() {
}

val pluginZip by tasks.creating(Zip::class) {
dependsOn(assemblePlugin)
dependsOn(tasks.assemble)
dependsOn(tasks.getByName("generateLicenseReport"))

fromCompileDependencies()
into(pluginId)
archiveBaseName.set(pluginName)
// fromCompileDependencies()
// into(pluginId)
from(tasks.assemble.get().outputs.files)
from(extensionJsonFile)
from("src/main/resources") {
include("dependencies.json")
}
from("src/main/resources") {
include("icon.svg")
rename("icon.svg", "pluginIcon.svg")
}
archiveBaseName.set(extension.id)
}

tasks.register("cleanAll", Delete::class.java) {
Expand All @@ -142,7 +194,7 @@ private fun getPluginInstallDir(): Path {
else -> error("Unknown os")
} / "plugins"

return pluginsDir / pluginId
return pluginsDir / extension.id
}

val publishPlugin by tasks.creating {
Expand All @@ -158,17 +210,45 @@ val publishPlugin by tasks.creating {
// instance.uploader.uploadNewPlugin(pluginZip.outputs.files.singleFile, listOf("toolbox", "gateway"), LicenseUrl.APACHE_2_0, ProductFamily.TOOLBOX)

// subsequent updates
instance.uploader.upload(pluginId, pluginZip.outputs.files.singleFile)
instance.uploader.upload(extension.id, pluginZip.outputs.files.singleFile)
}
}

// For use with kotlin-language-server.
tasks.register("classpath") {
doFirst {
File("classpath").writeText(
sourceSets["main"].runtimeClasspath.asPath
fun properties(key: String) = project.findProperty(key).toString()

gettext {
potFile = project.layout.projectDirectory.file("src/main/resources/localization/defaultMessages.pot")
keywords = listOf("ptrc:1c,2", "ptrl")
}

// region will be moved to the gradle plugin late
data class ExtensionJsonMeta(
val name: String,
val description: String,
val vendor: String,
val url: String?,
)

data class ExtensionJson(
val id: String,
val version: String,
val meta: ExtensionJsonMeta,
)

fun generateExtensionJson(extensionJson: ExtensionJson, destinationFile: Path) {
val descriptor = ToolboxPluginDescriptor(
id = extensionJson.id,
version = extensionJson.version,
apiVersion = libs.versions.toolbox.plugin.api.get(),
meta = ToolboxMeta(
name = extensionJson.meta.name,
description = extensionJson.meta.description,
vendor = extensionJson.meta.vendor,
url = extensionJson.meta.url,
)
}
)
val extensionJson = jacksonObjectMapper().writeValueAsString(descriptor)
destinationFile.parent.createDirectories()
destinationFile.writeText(extensionJson)
}

fun properties(key: String) = project.findProperty(key).toString()
// endregion
22 changes: 13 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
toolbox-plugin-api = "0.7.2.6.0.38311"
toolbox-plugin-api = "1.0.38881"
kotlin = "2.1.0"
coroutines = "1.10.1"
serialization = "1.8.0"
Expand All @@ -13,6 +13,8 @@ moshi = "1.15.1"
ksp = "2.1.0-1.0.29"
retrofit = "2.8.2"
changelog = "2.2.1"
gettext = "0.7.0"
plugin-structure = "3.298"

[libraries]
toolbox-core-api = { module = "com.jetbrains.toolbox:core-api", version.ref = "toolbox-plugin-api" }
Expand All @@ -25,21 +27,23 @@ serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serializatio
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
exec = { module = "org.zeroturnaround:zt-exec", version.ref = "exec" }
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi"}
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi"}
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit"}
retrofit-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit"}
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofit-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit" }
plugin-structure = { module = "org.jetbrains.intellij.plugins:structure-toolbox", version.ref = "plugin-structure" }

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

[bundles]
serialization = [ "serialization-core", "serialization-json", "serialization-json-okio" ]
toolbox-plugin-api = [ "toolbox-core-api", "toolbox-ui-api", "toolbox-remote-dev-api" ]
serialization = ["serialization-core", "serialization-json", "serialization-json-okio"]
toolbox-plugin-api = ["toolbox-core-api", "toolbox-ui-api", "toolbox-remote-dev-api"]

[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
dependency-license-report = { id = "com.github.jk1.dependency-license-report", version.ref = "dependency-license-report" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp"}
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
gradle-wrapper = { id = "me.filippov.gradle.jvm.wrapper", version.ref = "gradle-wrapper" }
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" }
gettext = { id = "name.kropp.kotlinx-gettext", version.ref = "gettext" }
15 changes: 0 additions & 15 deletions src/main/resources/extension.json

This file was deleted.

17 changes: 17 additions & 0 deletions src/main/resources/localization/defaultMessages.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2025 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# Ioan Faur <[email protected]>, 2025.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Coder Toolbox 1.0\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2025-03-04 12:00+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
Loading