I’m experimenting with custom scripts (the Tutoria...
# scripting
t
I’m experimenting with custom scripts (the Tutorials from https://kotlinlang.org/docs/custom-script-deps-tutorial.html and https://github.com/Kotlin/kotlin-script-examples/) trying to build a simple html generator (compiled and distributed in a fat jar) With this ScriptCompilationConfiguration:
Copy code
object HtmlTemplateScriptCompilationConfiguration : ScriptCompilationConfiguration(
	{
		defaultImports(
			"kotlinx.html.*",
			"name.voidi.table2web.html.*"
		)
		
		jvm {
			jvmTarget("19")
			
			dependenciesFromCurrentContext(
				"main",
				"kotlinx-html-jvm-0.8.0",
			)
		}
		
		ide {
			acceptedLocations(ScriptAcceptedLocation.Everywhere)
		}
	}
)
I got the following error: Caused by: kotlin.script.experimental.jvm.util.ClasspathExtractionException: Unable to get script compilation classpath from context, please specify explicit classpath via "kotlin.script.classpath" property How can specify the script dependencies direct in the compilation configuration?
i
Fat jars are tricky for the classpath extraction, so most likely the error you're getting describing the problem precisely. I'd suggest you to first try everything with the regular jars, and after you'll get all needed functionality, use your own method of extracting the classpath and add it in the script configuration with
updateDependencies
helper.
👍 1
t
Okay, now tried runnning directly via gradlew run i get the following error:
Copy code
Exception in thread "main" java.lang.ExceptionInInitializerError
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
        at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
...
        at name.voidi.table2web.MainKt.main(Main.kt:22)
Caused by: kotlin.script.experimental.jvm.util.ClasspathExtractionException: Unable to get script compilation classpath from context, please specify explicit classpath via "kotlin.script.classpath" property