File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 11import java.nio.file.Files
22
3+ import java.nio.charset.Charset
4+
35import org.graalvm.buildtools.gradle.tasks.BuildNativeImageTask
46
57plugins {
@@ -26,6 +28,46 @@ dependencies {
2628 implementation(libs.kotlinReflect)
2729}
2830
31+ val jar by tasks.getting(Jar ::class )
32+
33+ val pathingJar by tasks.registering(Jar ::class ) {
34+ archiveClassifier = " pathing"
35+
36+ manifest {
37+ // Work around the command line length limit on Windows when passing the classpath to Java, see
38+ // https://github.com/gradle/gradle/issues/1989.
39+ attributes[" Class-Path" ] = configurations.runtimeClasspath.get().joinToString(" " ) { it.name }
40+ }
41+ }
42+
43+ distributions {
44+ main {
45+ contents {
46+ from(pathingJar) {
47+ into(" lib" )
48+ }
49+ }
50+ }
51+ }
52+
53+ tasks.named<CreateStartScripts >(" startScripts" ) {
54+ classpath = jar.outputs.files + pathingJar.get().outputs.files
55+
56+ doLast {
57+ // Append the plugin directory to the Windows classpath.
58+ val windowsScriptText = windowsScript.readText(Charset .defaultCharset())
59+ windowsScript.writeText(
60+ windowsScriptText.replace(Regex (" (set CLASSPATH=%APP_HOME%\\\\ lib\\\\ .*)" ), " $1;%APP_HOME%\\\\ plugin\\\\ *" )
61+ )
62+
63+ // Append the plugin directory to the Unix classpath.
64+ val unixScriptText = unixScript.readText(Charset .defaultCharset())
65+ unixScript.writeText(
66+ unixScriptText.replace(Regex (" (CLASSPATH=\\ \$ APP_HOME/lib/.*)" ), " $1:\\ \$ APP_HOME/plugin/*" )
67+ )
68+ }
69+ }
70+
2971graalvmNative {
3072 toolchainDetection = System .getenv(" GRAALVM_HOME" ) == null
3173
You can’t perform that action at this time.
0 commit comments