Skip to content

Add runtime plugin for generating stand-alone images #159

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

Merged
merged 5 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/workflows/deploy.yml

This file was deleted.

160 changes: 144 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

import java.util.regex.Pattern

buildscript {
repositories {
Expand All @@ -33,10 +34,13 @@ plugins {
id "application"

id "maven-publish"
id "signing"
id "com.palantir.git-version" version "0.12.3"
id "checkstyle"
id "org.jreleaser" version "1.13.0"

// Fork of runtime plugin with java 21 support, until https://github.com/beryx/badass-runtime-plugin/issues/153
// is resolved.
id "com.dua3.gradle.runtime" version "1.13.1-patch-1"
}


Expand Down Expand Up @@ -69,6 +73,8 @@ task javadocJar(type: Jar) {
ext {
// Load the Smithy Language Server version from VERSION.
libraryVersion = project.file("VERSION").getText('UTF-8').replace(System.lineSeparator(), "")
imageJreVersion = "21"
correttoRoot = "https://corretto.aws/downloads/latest/amazon-corretto-${imageJreVersion}"
}

println "Smithy Language Server version: '${libraryVersion}'"
Expand All @@ -78,7 +84,6 @@ def stagingDirectory = rootProject.layout.buildDirectory.dir("staging")
allprojects {
apply plugin: "java"
apply plugin: "maven-publish"
apply plugin: "signing"
group = "software.amazon.smithy"
version = libraryVersion
description = "Language Server Protocol implementation for Smithy"
Expand Down Expand Up @@ -228,31 +233,154 @@ jar {
}
}


runtime {
addOptions("--compress", "2", "--strip-debug", "--no-header-files", "--no-man-pages")
addModules("java.logging")

launcher {
jvmArgs = [
'-XX:-UsePerfData',
'-Xshare:auto',
'-XX:SharedArchiveFile={{BIN_DIR}}/../lib/smithy.jsa'
]
}

targetPlatform("linux-x86_64") {
jdkHome = jdkDownload("${correttoRoot}-x64-linux-jdk.tar.gz")
}

targetPlatform("linux-aarch64") {
jdkHome = jdkDownload("${correttoRoot}-aarch64-linux-jdk.tar.gz")
}

targetPlatform("darwin-x86_64") {
jdkHome = jdkDownload("${correttoRoot}-x64-macos-jdk.tar.gz")
}

targetPlatform("darwin-aarch64") {
jdkHome = jdkDownload("${correttoRoot}-aarch64-macos-jdk.tar.gz")
}

targetPlatform("windows-x64") {
jdkHome = jdkDownload("${correttoRoot}-x64-windows-jdk.zip")
}

// Because we're using target-platforms, it will use this property as a prefix for each target zip
imageZip = layout.buildDirectory.file("image/smithy-language-server.zip")
}

tasks["assembleDist"].dependsOn("publish")
tasks["assembleDist"].dependsOn("runtimeZip")

// Generate a changelog that only includes the changes for the latest version
// which Jreleaser will add to the release notes of the github release.
def releaseChangelogFile = project.layout.buildDirectory.file("resources/RELEASE_CHANGELOG.md").get().asFile
tasks.register("createReleaseChangelog") {
dependsOn processResources

doLast {
def changelog = project.file("CHANGELOG.md").text
// Copy the text in between the first two version headers
def matcher = Pattern.compile("^## \\d+\\.\\d+\\.\\d+", Pattern.MULTILINE).matcher(changelog)
def getIndex = {
matcher.find()
return matcher.start()
}
def result = changelog.substring(getIndex(), getIndex()).trim()
releaseChangelogFile.write(result)
}
}

tasks.jreleaserRelease.dependsOn(tasks.createReleaseChangelog)

jreleaser {
dryrun = false

// Used for creating a tagged release, uploading files and generating changelog.
// In the future we can set this up to push release tags to GitHub, but for now it's
// set up to do nothing.
// https://jreleaser.org/guide/latest/reference/release/index.html
project {
website = 'https://smithy.io'
authors = ['Smithy']
vendor = "Smithy"
license = 'Apache-2.0'
description = "Smithy Language Server - A Language Server Protocol implementation for the Smithy IDL."
copyright = "2019"
}

release {
generic {
enabled = true
skipRelease = true
github {
overwrite = true
tagName = '{{projectVersion}}'
releaseName = 'Smithy Language Server v{{{projectVersion}}}'
changelog {
external = releaseChangelogFile.absolutePath
}
commitAuthor {
name = "smithy-automation"
email = "[email protected]"
}
}
}

// Used to announce a release to configured announcers.
// https://jreleaser.org/guide/latest/reference/announce/index.html
announce {
active = "NEVER"
files {
active = "ALWAYS"
artifact {
// We'll include the VERSION file in the release artifacts so that the version can be easily
// retrieving by hitting the GitHub `releases/latest` url
path = "VERSION"
extraProperties.put('skipSigning', true)
}
}

platform {
// These replacements are for the names of files that are released, *not* for names within this build config
replacements = [
'osx': 'darwin',
'aarch_64': 'aarch64',
'windows_x86_64': 'windows_x64'
]
}

distributions {
'smithy-language-server' {
distributionType = 'JLINK'
stereotype = 'CLI'

artifact {
path = "build/image/smithy-language-server-linux-x86_64.zip"
platform = "linux-x86_64"
}

artifact {
path = "build/image/smithy-language-server-linux-aarch64.zip"
platform = "linux-aarch_64"
}

artifact {
path = "build/image/smithy-language-server-darwin-x86_64.zip"
platform = "osx-x86_64"
}

artifact {
path = "build/image/smithy-language-server-darwin-aarch64.zip"
platform = "osx-aarch_64"
}

artifact {
path = "build/image/smithy-language-server-windows-x64.zip"
platform = "windows-x86_64"
}
}
}

checksum {
individual = true
files = false
}

// Signing configuration.
// https://jreleaser.org/guide/latest/reference/signing.html
signing {
active = "ALWAYS"
active = "RELEASE"
armored = true
verify = true
}

// Configuration for deploying to Maven Central.
Expand Down