I might find a bug in kotlin-scripting (v1.3.31). ...
# scripting
l
I might find a bug in kotlin-scripting (v1.3.31). The code is as follows:
Copy code
@KotlinScript(fileExtension = "simplescript.kts")
abstract class SimpleScript

fun main() {
    val config = createJvmCompilationConfigurationFromTemplate<SimpleScript> {
        jvm {
            dependenciesFromCurrentContext(wholeClasspath = true)
        }
    }

    val s = """
        println("This is a test!")
    """.trimIndent()

    val res = BasicJvmScriptingHost().eval(s.toScriptSource("script-name"), config, null)
    println(res)
}
Running this program, the following error is reported:
Copy code
Failure(reports=[ScriptDiagnostic(message=Not a script file, severity=ERROR, sourcePath=null, location=null, exception=null)])
But if I remove the argument
"script-name"
from
s.toScriptSource()
. Everything will be fine. Could anyone from JB confirm it? Thanks!
a
l
Yes. I opened this one.
i
Thanks for reporting. I answered in the issue. Basically you need to specify the full name with the extension, as defined by the
KotlinScript
annotation (“.simplescript.kts” in the sample). But in this scenarion we can probably add the extension on our side, so I’m leaving the issue open.
l
👍