Skip to content

Commit 9cd6fd0

Browse files
authored
Simplify installation (#234)
Simplifies the installation process of the runtime images we release, for humans as well as editor plugins that want to automatically install/update the language server. First thing I did was change the name of the release artifact for windows x64 from `windows-x64` to `windows-x86_64`. They generally refer to the same thing, and both the linux and mac x64 artifacts use x86_64, so automated downloads don't have to special case windows. The next thing I did was make it so the zips we release of the runtime images have a flat directory structure. By default (and seemingly with no way to change it), the runtime plugin creates a zip where the first entry is the directory being zipped. For example: ``` > unzip smithy-language-server-darwin-aarch64.zip > ls smithy-language-server-darwin-aarch64.zip smithy-language-server-darwin-aarch64/ ``` This commit makes it: ``` > unzip smithy-language-server-darwin-aarch64.zip > ls smithy-language-server-darwin-aarch64.zip bin/ conf/ ... you get the idea ``` Since the plugin doesn't provide you with a way to do this, I had to use some gradle wizardry to essentially override the default `runtimeZip` task so the task dependency graph stayed the same. The comment in build.gradle.kts has more details on how it works, but it basically just makes a custom Zip task for each target.
1 parent 341ed01 commit 9cd6fd0

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ For example, on an ARM Mac:
2121

2222
```shell
2323
curl -o download.zip -L "https://github.com/smithy-lang/smithy-language-server/releases/latest/download/smithy-language-server-darwin-aarch64.zip"
24-
unzip download.zip
25-
smithy-language-server-darwin-aarch64/bin/smithy-language-server --help
24+
unzip download.zip -d smithy-language-server
25+
smithy-language-server/bin/smithy-language-server --help
2626
```
2727

2828
Run smithy-language-server by running the launch script with no arguments - this

build.gradle.kts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,36 @@ runtime {
245245
jdkHome = jdkDownload("${correttoRoot}-aarch64-macos-jdk.tar.gz")
246246
}
247247

248-
targetPlatform("windows-x64") {
248+
targetPlatform("windows-x86_64") {
249249
jdkHome = jdkDownload("${correttoRoot}-x64-windows-jdk.zip")
250250
}
251251

252-
// Because we're using target-platforms, it will use this property as a prefix for each target zip
253-
imageZip = layout.buildDirectory.file("image/smithy-language-server.zip")
252+
// This block creates a custom `Zip` task for each `targetPlatform`, which zip up the contents of
253+
// the platform's runtime image directory created by the runtime plugin. These tasks replace the
254+
// action of `runtimeZip`.
255+
//
256+
// The only difference between this and what the runtime plugin does by default, is that the
257+
// plugin zips each runtime image _directory_, whereas this zips each directory's _contents_.
258+
// For example, with the runtime plugin's zips, if you `unzip smithy-language-server-<platform>.zip`,
259+
// the launch script will be `./smithy-language-server-<platform>/bin/smithy-language-server`. With
260+
// this, it will just be `./bin/smithy-language-server`. This makes it easier to download and run
261+
// because there isn't an extra directory to go through, with a platform-dependent name.
262+
afterEvaluate {
263+
val runtimeZipTasks = targetPlatforms.get().keys.map { platformName ->
264+
tasks.register<Zip>("runtimeZip$platformName") {
265+
dependsOn(tasks.runtime)
266+
267+
archiveFileName = "smithy-language-server-$platformName.zip"
268+
destinationDirectory = layout.buildDirectory.dir("image")
269+
from(layout.buildDirectory.dir("image/smithy-language-server-$platformName"))
270+
}
271+
}
272+
273+
tasks.runtimeZip {
274+
dependsOn(runtimeZipTasks)
275+
actions.clear()
276+
}
277+
}
254278
}
255279

256280
jreleaser {
@@ -298,7 +322,6 @@ jreleaser {
298322
replacements = mapOf(
299323
"osx" to "darwin",
300324
"aarch_64" to "aarch64",
301-
"windows_x86_64" to "windows_x64"
302325
)
303326
}
304327

@@ -328,7 +351,7 @@ jreleaser {
328351
}
329352

330353
artifact {
331-
path = layout.buildDirectory.file("image/smithy-language-server-windows-x64.zip")
354+
path = layout.buildDirectory.file("image/smithy-language-server-windows-x86_64.zip")
332355
platform = "windows-x86_64"
333356
}
334357
}

0 commit comments

Comments
 (0)