Bump GraalVM to 25.0.0 (#1226)

* Migrate shadow plugin to org.gradleup to correctly bundle Truffle in
  a fat jar
* Switch to GraalVM Community Edition
This commit is contained in:
Daniel Chao
2025-10-07 21:23:15 -07:00
committed by GitHub
parent cecaf39aff
commit 55eac2088b
19 changed files with 217 additions and 199 deletions

View File

@@ -84,12 +84,13 @@ open class BuildInfo(private val project: Project) {
}
}
val baseName: String by lazy { "graalvm-jdk-${graalVmJdkVersion}_${osName}-${arch}_bin" }
val baseName: String by lazy {
"graalvm-community-jdk-${graalVmJdkVersion}_${osName}-${arch}_bin"
}
val downloadUrl: String by lazy {
val jdkMajor = graalVmJdkVersion.takeWhile { it != '.' }
val extension = if (os.isWindows) "zip" else "tar.gz"
"https://download.oracle.com/graalvm/$jdkMajor/archive/$baseName.$extension"
"https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${graalVmJdkVersion}/$baseName.$extension"
}
val downloadFile: File by lazy {

View File

@@ -15,7 +15,6 @@
*/
import org.gradle.api.GradleException
import org.gradle.api.artifacts.Configuration
import org.gradle.api.component.AdhocComponentWithVariants
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.testing.Test
@@ -24,7 +23,7 @@ import org.gradle.kotlin.dsl.*
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow")
id("com.gradleup.shadow")
}
// make fat Jar available to other subprojects
@@ -94,6 +93,8 @@ tasks.shadowJar {
configurations = listOf(project.configurations.runtimeClasspath.get())
addMultiReleaseAttribute = true
// not required at runtime / fat JARs can't be used in native-image builds anyway
exclude("org/pkl/cli/svm/**")
@@ -129,10 +130,7 @@ tasks.shadowJar {
mergeServiceFiles()
}
// workaround for https://github.com/johnrengelman/shadow/issues/651
components.withType(AdhocComponentWithVariants::class.java).forEach { c ->
c.withVariantsFromConfiguration(project.configurations.shadowRuntimeElements.get()) { skip() }
}
shadow { addShadowVariantIntoJavaComponent = false }
val testFatJar by
tasks.registering(Test::class) {
@@ -210,7 +208,7 @@ artifacts { add("fatJar", tasks.shadowJar) }
publishing {
publications {
named<MavenPublication>("fatJar") {
project.shadow.component(this)
from(components["shadow"])
// sources Jar is fat
artifact(fatSourcesJar.flatMap { it.outputJar.asFile }) { classifier = "sources" }

View File

@@ -20,7 +20,7 @@ import org.gradle.kotlin.dsl.support.serviceOf
plugins {
id("pklJavaLibrary")
// id("pklPublishLibrary")
id("com.github.johnrengelman.shadow")
id("com.gradleup.shadow")
}
val executableSpec = project.extensions.create("executable", ExecutableSpec::class.java)

View File

@@ -15,13 +15,14 @@
*/
import kotlin.io.path.createDirectories
import kotlin.io.path.writeText
import org.gradle.accessors.dm.LibrariesForLibs
plugins {
id("pklGraalVm")
id("pklJavaLibrary")
id("pklNativeLifecycle")
id("pklPublishLibrary")
id("com.github.johnrengelman.shadow")
id("com.gradleup.shadow")
}
// assumes that `pklJavaExecutable` is also applied
@@ -35,6 +36,19 @@ val stagedLinuxAarch64Executable: Configuration by configurations.creating
val stagedAlpineLinuxAmd64Executable: Configuration by configurations.creating
val stagedWindowsAmd64Executable: Configuration by configurations.creating
val nativeImageClasspath by
configurations.creating {
extendsFrom(configurations.runtimeClasspath.get())
// Ensure native-image version uses GraalVM C SDKs instead of Java FFI or JNA
// (comes from artifact `mordant-jvm-graal-ffi`).
exclude("com.github.ajalt.mordant", "mordant-jvm-ffm")
exclude("com.github.ajalt.mordant", "mordant-jvm-ffm-jvm")
exclude("com.github.ajalt.mordant", "mordant-jvm-jna")
exclude("com.github.ajalt.mordant", "mordant-jvm-jna-jvm")
}
val libs = the<LibrariesForLibs>()
dependencies {
fun executableFile(suffix: String) =
files(
@@ -42,6 +56,9 @@ dependencies {
dir.file(executableSpec.name.map { "$it-$suffix" })
}
)
nativeImageClasspath(libs.truffleRuntime)
nativeImageClasspath(libs.graalSdk)
stagedMacAarch64Executable(executableFile("macos-aarch64"))
stagedMacAmd64Executable(executableFile("macos-amd64"))
stagedLinuxAmd64Executable(executableFile("linux-amd64"))
@@ -65,7 +82,7 @@ private fun NativeImageBuild.setClasspath() {
classpath.from(
project(":pkl-commons-cli").extensions.getByType(SourceSetContainer::class)["svm"].output
)
classpath.from(configurations.runtimeClasspath)
classpath.from(nativeImageClasspath)
}
val macExecutableAmd64 by