- Notifications
You must be signed in to change notification settings - Fork1
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
99e56cf
059f3fc
d0af2c9
7cfd6f5
4e5ef77
11be558
9a2c44a
09c99d1
cce41b0
d75d0c7
142a587
477d6ec
42e4ca5
42ac589
d4f933a
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import com.fasterxml.jackson.databind.SerializationFeature | ||
import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder | ||
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 +20,31 @@ plugins { | ||
alias(libs.plugins.ksp) | ||
alias(libs.plugins.gradle.wrapper) | ||
alias(libs.plugins.changelog) | ||
alias(libs.plugins.gettext) | ||
} | ||
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" | ||
fioan89 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
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,24 +53,43 @@ jvmWrapper { | ||
dependencies { | ||
compileOnly(libs.bundles.toolbox.plugin.api) | ||
compileOnly(libs.bundles.serialization) | ||
compileOnly(libs.coroutines.core) | ||
implementation(libs.okhttp) | ||
implementation(libs.exec) | ||
implementation(libs.moshi) | ||
ksp(libs.moshi.codegen) | ||
implementation(libs.retrofit) | ||
implementation(libs.retrofit.moshi) | ||
testImplementation(kotlin("test")) | ||
testImplementation(libs.mokk) | ||
testImplementation(libs.bundles.toolbox.plugin.api) | ||
} | ||
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(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,24 +109,30 @@ tasks.test { | ||
useJUnitPlatform() | ||
} | ||
tasks.jar { | ||
archiveBaseName.set(extension.id) | ||
dependsOn(extensionJson) | ||
from(extensionJson.get().outputs) | ||
} | ||
val copyPlugin by tasks.creating(Sync::class.java) { | ||
dependsOn(tasks.jar) | ||
dependsOn(tasks.getByName("generateLicenseReport")) | ||
fromCompileDependencies() | ||
into(getPluginInstallDir()) | ||
} | ||
fun CopySpec.fromCompileDependencies() { | ||
from(tasks.jar) | ||
from(extensionJson.get().outputs.files) | ||
from("src/main/resources") { | ||
include("dependencies.json") | ||
} | ||
from("src/main/resources") { | ||
include("icon.svg") | ||
rename("icon.svg", "pluginIcon.svg") | ||
} | ||
// Copy dependencies, excluding those provided by Toolbox. | ||
@@ -106,18 +145,20 @@ fun CopySpec.fromCompileDependencies() { | ||
"core-api", | ||
"ui-api", | ||
"annotations", | ||
"localization-api" | ||
).any { file.name.contains(it) } | ||
} | ||
}, | ||
) | ||
} | ||
val pluginZip by tasks.creating(Zip::class) { | ||
archiveBaseName.set(properties("name")) | ||
dependsOn(tasks.jar) | ||
dependsOn(tasks.getByName("generateLicenseReport")) | ||
fromCompileDependencies() | ||
into(extension.id) // folder like com.coder.toolbox | ||
} | ||
tasks.register("cleanAll", Delete::class.java) { | ||
@@ -142,7 +183,7 @@ private fun getPluginInstallDir(): Path { | ||
else -> error("Unknown os") | ||
} / "plugins" | ||
return pluginsDir /extension.id | ||
fioan89 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
val publishPlugin by tasks.creating { | ||
@@ -158,17 +199,49 @@ 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(extension.id, pluginZip.outputs.files.singleFile) | ||
fioan89 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
} | ||
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, | ||
) | ||
) | ||
destinationFile.parent.createDirectories() | ||
destinationFile.writeText( | ||
jacksonMapperBuilder() | ||
.enable(SerializationFeature.INDENT_OUTPUT) | ||
.build() | ||
.writeValueAsString(descriptor) | ||
) | ||
} | ||
// endregion |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.