Skip to content

Commit fb68191

Browse files
committed
build: task to remove compile artifacts and installed artifacts
- quality of life improvement to automate some recurring manual tasks like cleaning up the plugin install dir
1 parent d1e4e95 commit fb68191

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

Diff for: build.gradle.kts

+26-19
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,7 @@ val assemblePlugin by tasks.registering(Jar::class) {
7777
val copyPlugin by tasks.creating(Sync::class.java) {
7878
dependsOn(assemblePlugin)
7979

80-
val userHome = System.getProperty("user.home").let { Path.of(it) }
81-
val toolboxCachesDir = when {
82-
SystemInfoRt.isWindows -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
83-
// currently this is the location that TBA uses on Linux
84-
SystemInfoRt.isLinux -> System.getenv("XDG_DATA_HOME")?.let { Path.of(it) } ?: (userHome / ".local" / "share")
85-
SystemInfoRt.isMac -> userHome / "Library" / "Caches"
86-
else -> error("Unknown os")
87-
} / "JetBrains" / "Toolbox"
88-
89-
val pluginsDir = when {
90-
SystemInfoRt.isWindows -> toolboxCachesDir / "cache"
91-
SystemInfoRt.isLinux || SystemInfoRt.isMac -> toolboxCachesDir
92-
else -> error("Unknown os")
93-
} / "plugins"
94-
95-
val targetDir = pluginsDir / pluginId
96-
9780
from(assemblePlugin.get().outputs.files)
98-
9981
from("src/main/resources") {
10082
include("extension.json")
10183
include("dependencies.json")
@@ -117,7 +99,32 @@ val copyPlugin by tasks.creating(Sync::class.java) {
11799
},
118100
)
119101

120-
into(targetDir)
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 {
112+
val userHome = System.getProperty("user.home").let { Path.of(it) }
113+
val toolboxCachesDir = when {
114+
SystemInfoRt.isWindows -> System.getenv("LOCALAPPDATA")?.let { Path.of(it) } ?: (userHome / "AppData" / "Local")
115+
// currently this is the location that TBA uses on Linux
116+
SystemInfoRt.isLinux -> System.getenv("XDG_DATA_HOME")?.let { Path.of(it) } ?: (userHome / ".local" / "share")
117+
SystemInfoRt.isMac -> userHome / "Library" / "Caches"
118+
else -> error("Unknown os")
119+
} / "JetBrains" / "Toolbox"
120+
121+
val pluginsDir = when {
122+
SystemInfoRt.isWindows -> toolboxCachesDir / "cache"
123+
SystemInfoRt.isLinux || SystemInfoRt.isMac -> toolboxCachesDir
124+
else -> error("Unknown os")
125+
} / "plugins"
126+
127+
return pluginsDir / pluginId
121128
}
122129

123130
val pluginZip by tasks.creating(Zip::class) {

0 commit comments

Comments
 (0)