-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 2 commits
99e56cf
059f3fc
d0af2c9
7cfd6f5
4e5ef77
11be558
9a2c44a
09c99d1
cce41b0
d75d0c7
142a587
477d6ec
42e4ca5
42ac589
d4f933a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
|
@@ -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" | ||
|
@@ -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) | ||
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to call plugin an extension from now on? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
} | ||
|
@@ -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()) | ||
} | ||
|
||
|
@@ -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") | ||
fioan89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
archiveBaseName.set(extension.id) | ||
} | ||
|
||
tasks.register("cleanAll", Delete::class.java) { | ||
|
@@ -142,7 +194,7 @@ private fun getPluginInstallDir(): Path { | |
else -> error("Unknown os") | ||
} / "plugins" | ||
|
||
return pluginsDir / pluginId | ||
return pluginsDir / extension.id | ||
fioan89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
val publishPlugin by tasks.creating { | ||
|
@@ -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) | ||
fioan89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
// 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 |
This file was deleted.
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" | ||
fioan89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"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" |
Uh oh!
There was an error while loading. Please reload this page.