Skip to content

Commit 9fb7308

Browse files
committed
build: Remove a work-around for older GraalVM releases
The recent GraalVM releases support Java 20 (and 21), so the task can be reconfigured unconditionally. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 67ff91a commit 9fb7308

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

buildSrc/src/main/kotlin/ort-application-conventions.gradle.kts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -115,36 +115,32 @@ graalvmNative {
115115
}
116116
}
117117

118-
// JDK 20 will only be supported starting with GraalVM 23, see
119-
// https://www.graalvm.org/release-notes/release-calendar/#planned-releases
120-
if (JavaVersion.current().majorVersion.toInt() <= 19) {
121-
tasks.named<BuildNativeImageTask>("nativeCompile") {
122-
// Gradle's "Copy" task cannot handle symbolic links, see https://github.com/gradle/gradle/issues/3982. That is
123-
// why links contained in the GraalVM distribution archive get broken during provisioning and are replaced by
124-
// empty files. Address this by recreating the links in the toolchain directory.
125-
val toolchainDir = options.get().javaLauncher.get().executablePath.asFile.parentFile.run {
126-
if (name == "bin") parentFile else this
127-
}
118+
tasks.named<BuildNativeImageTask>("nativeCompile") {
119+
// Gradle's "Copy" task cannot handle symbolic links, see https://github.com/gradle/gradle/issues/3982. That is why
120+
// links contained in the GraalVM distribution archive get broken during provisioning and are replaced by empty
121+
// files. Address this by recreating the links in the toolchain directory.
122+
val toolchainDir = options.get().javaLauncher.get().executablePath.asFile.parentFile.run {
123+
if (name == "bin") parentFile else this
124+
}
128125

129-
val toolchainFiles = toolchainDir.walkTopDown().filter { it.isFile }
130-
val emptyFiles = toolchainFiles.filter { it.length() == 0L }
126+
val toolchainFiles = toolchainDir.walkTopDown().filter { it.isFile }
127+
val emptyFiles = toolchainFiles.filter { it.length() == 0L }
131128

132-
// Find empty toolchain files that are named like other toolchain files and assume these should have been links.
133-
val links = toolchainFiles.mapNotNull { file ->
134-
emptyFiles.singleOrNull { it != file && it.name == file.name }?.let {
135-
file to it
136-
}
129+
// Find empty toolchain files that are named like other toolchain files and assume these should have been links.
130+
val links = toolchainFiles.mapNotNull { file ->
131+
emptyFiles.singleOrNull { it != file && it.name == file.name }?.let {
132+
file to it
137133
}
134+
}
138135

139-
// Fix up symbolic links.
140-
links.forEach { (target, link) ->
141-
logger.quiet("Fixing up '$link' to link to '$target'.")
136+
// Fix up symbolic links.
137+
links.forEach { (target, link) ->
138+
logger.quiet("Fixing up '$link' to link to '$target'.")
142139

143-
if (link.delete()) {
144-
Files.createSymbolicLink(link.toPath(), target.toPath())
145-
} else {
146-
logger.warn("Unable to delete '$link'.")
147-
}
140+
if (link.delete()) {
141+
Files.createSymbolicLink(link.toPath(), target.toPath())
142+
} else {
143+
logger.warn("Unable to delete '$link'.")
148144
}
149145
}
150146
}

0 commit comments

Comments
 (0)