In Kotlin 1.4 scripting is it possible to include/...
# scripting
d
In Kotlin 1.4 scripting is it possible to include/import a script in another script? The idea is I want to write some reusable utility functions somewhere and then include them in a script I intend to actually run.
Turns out if I add a
@file:Import
it works but the function name shows up as invalid (suggests I implement it), but running it does resolve the function.
i
That's because imported scripts are a part of configuration, and configurations are not reloaded automatically. Try to enable auto-reloading of configurations for script definitions you use:
d
Hm, seemed to be a caching issue of some sort. Now it’s showing the function as valid, but is also showing any function I invoke as being valid until I execute.
Ah cool let me try
It’s very very slow now, but also still experiencing the same issue: every function appears valid until I run it
i
Hm, it actually may be https://youtrack.jetbrains.com/issue/KTIJ-1194 In your case it lacks the comparison of
importedScripts
. Please describe your case there and vote for this issue
p
I had to extract my utility methods as maven artifacts for this purpose... Not the easiest solution but (at least) it's allowing me to share logic between scripts, whatever their repository