Skip to content

Commit dc01ed9

Browse files
authored
Merge pull request #1 from IvanPashchenko/main
added script to copy the plugin to test it in the TBA
2 parents 1143961 + bdc733e commit dc01ed9

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

build.gradle.kts

+51
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import org.jetbrains.kotlin.com.intellij.openapi.util.SystemInfoRt
2+
import java.nio.file.Path
3+
import kotlin.io.path.div
4+
15
plugins {
26
alias(libs.plugins.kotlin)
37
alias(libs.plugins.serialization)
@@ -22,3 +26,50 @@ tasks.compileKotlin {
2226
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
2327
)
2428
}
29+
30+
val pluginId = "sample"
31+
32+
val assemblePlugin by tasks.registering(Jar::class) {
33+
archiveBaseName.set(pluginId)
34+
from(sourceSets.main.get().output)
35+
}
36+
37+
val copyPlugin by tasks.creating(Copy::class.java) {
38+
dependsOn(assemblePlugin)
39+
40+
val userHome = System.getProperty("user.home").let { Path.of(it) }
41+
val toolboxCachesDir = when {
42+
SystemInfoRt.isWindows -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
43+
// currently this is the location that TBA uses on Linux
44+
SystemInfoRt.isLinux -> System.getenv("XDG_DATA_HOME")?.let { Path.of(it) } ?: (userHome / ".local" / "share")
45+
SystemInfoRt.isMac -> userHome / "Library" / "Caches"
46+
else -> error("Unknown os")
47+
} / "JetBrains" / "Toolbox"
48+
49+
val pluginsDir = when {
50+
SystemInfoRt.isWindows -> toolboxCachesDir / "cache"
51+
SystemInfoRt.isLinux || SystemInfoRt.isMac -> toolboxCachesDir
52+
else -> error("Unknown os")
53+
} / "plugins"
54+
55+
val targetDir = pluginsDir / pluginId
56+
val runtimeClasspath by configurations.getting
57+
58+
from(assemblePlugin.get().outputs.files)
59+
60+
val excludedJarPrefixes = listOf("gateway-api")
61+
val filteredClasspath = runtimeClasspath.filter { f ->
62+
!excludedJarPrefixes.any { p -> f.name.startsWith(p) }
63+
}
64+
65+
from(filteredClasspath) {
66+
include("*.jar")
67+
}
68+
69+
from("src/main/resources") {
70+
include("extensions.json")
71+
include("icon.svg")
72+
}
73+
74+
into(targetDir)
75+
}

0 commit comments

Comments
 (0)