I’ve created a project following tutorial Get started with Kotlin custom scripting – tutorial | Kotlin
I’ve managed to run my scripts from IDEA as in tutorial. But it is hard to create a run configuration for every script. How would I do this this command-line?
I’ve tried to use “shadow” plugin to build an uber-jar from host application. But when I run it I get
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:1042)
at java.base/jdk.internal.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:186)
at java.base/java.lang.reflect.Field.acquireFieldAccessor(Field.java:1105)
at java.base/java.lang.reflect.Field.getFieldAccessor(Field.java:1086)
at java.base/java.lang.reflect.Field.get(Field.java:418)
at kotlin.reflect.jvm.internal.KClassImpl$Data$objectInstance$2.invoke(KClassImpl.kt:117)
at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:63)
at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:32)
at kotlin.reflect.jvm.internal.KClassImpl$Data.getObjectInstance(KClassImpl.kt:108)
at kotlin.reflect.jvm.internal.KClassImpl.getObjectInstance(KClassImpl.kt:242)
at kotlin.script.experimental.host.ConfigurationFromTemplateKt.constructCompilationConfiguration(configurationFromTemplate.kt:199)
at kotlin.script.experimental.host.ConfigurationFromTemplateKt.createScriptDefinitionFromTemplate(configurationFromTemplate.kt:42)
at internal.mynd.HostKt.evalFile(host.kt:74)
at internal.mynd.HostKt.main(host.kt:19)
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
at kotlin.script.experimental.jvm.util.JvmClasspathUtilKt.scriptCompilationClasspathFromContext(jvmClasspathUtil.kt:345)
at kotlin.script.experimental.jvm.JvmScriptCompilationKt.dependenciesFromClassloader(jvmScriptCompilation.kt:57)
at kotlin.script.experimental.jvm.JvmScriptCompilationKt.dependenciesFromClassloader$default(jvmScriptCompilation.kt:50)
at kotlin.script.experimental.jvm.JvmScriptCompilationKt.dependenciesFromClassContext(jvmScriptCompilation.kt:39)
at kotlin.script.experimental.jvm.JvmScriptCompilationKt.dependenciesFromClassContext$default(jvmScriptCompilation.kt:36)
at internal.mynd.TemplatesScriptConfiguration$1$1.invoke(scriptDef.kt:19)
at internal.mynd.TemplatesScriptConfiguration$1$1.invoke(scriptDef.kt:18)
at kotlin.script.experimental.util.PropertiesCollection$Builder.invoke(propertiesCollection.kt:282)
at internal.mynd.TemplatesScriptConfiguration$1.invoke(scriptDef.kt:18)
at internal.mynd.TemplatesScriptConfiguration$1.invoke(scriptDef.kt:17)
at kotlin.script.experimental.api.ScriptCompilationConfiguration.<init>(scriptCompilation.kt:23)
at kotlin.script.experimental.api.ScriptCompilationConfiguration.<init>(scriptCompilation.kt:25)
at internal.mynd.TemplatesScriptConfiguration.<init>(scriptDef.kt:17)
at internal.mynd.TemplatesScriptConfiguration.<clinit>(scriptDef.kt)
... 16 more