elect
07/14/2022, 7:10 AMmain
(as suggested by docs) then the evaluation and configuration gets called. If I try using the IDE instead, no. Is this expected? Do I have to do something special for the Idea to recognize them? (ie meta-inf)@KotlinScript
and host execution/evaluation, however at the moment I'm testing via main
and I'm building my cfg as:
private fun File.evaluate(): ResultWithDiagnostics<EvaluationResult> {
val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<Script> {
jvm {
dependenciesFromCurrentContext(wholeClasspath = true)
}
defaultImports(Import::class)
refineConfiguration {
onAnnotations(Import::class, handler = handler)
}
}
return BasicJvmScriptingHost().eval(toScriptSource(), compilationConfiguration, ScriptEvaluationConfiguration().with {
constructorArgs(name)
})
}
the moment I try to extract this logic into a class (in order to pass it to @KotlinScript
as well) like:
class TfConfiguration : ScriptCompilationConfiguration(createJvmCompilationConfigurationFromTemplate<Script>(), body = {
jvm {
dependenciesFromCurrentContext(wholeClasspath = true)
}
defaultImports(Import::class)
refineConfiguration {
onAnnotations(Import::class, handler = handler)
}
})
then I get this enormous stacktraceilya.chernikov
07/20/2022, 7:16 AMkotlinc
or scripting subsystems in the IntelliJ is able to use the script. It seems you've already mentioned "simple main kts", so it shouws the correct way.ScriptDefinitionsProvider
extension point.
But you can test it locally (disclaimer - this is not an officially supported way) by going to kotlin compilersettings page in the IntelliJ settings, find two empty entry fields at the bottom in the section "Scripting", and enter the FQN of your script definition class (the one marked with @KotlinScript
) into the first one, and the classpath needed to load it into the second.elect
07/20/2022, 7:54 AMMETA-INF.kotlin.script.templates
?) and the absolute path on the system to load it, but I keep getting
warning: default scripting plugin is disabled: The provided plugin org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar is not compatible with this version of compiler
error: unable to evaluate script, no scripting plugin loaded
ilya.chernikov
07/20/2022, 8:22 AMsmain
script. Please add this info to the issue then you'll be filing it.elect
07/20/2022, 8:24 AM