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.
Dave K
04/07/2021, 9:30 PM
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
Ilya Muradyan
04/07/2021, 9:35 PM
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
Dave K
04/07/2021, 9:35 PM
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.
Dave K
04/07/2021, 9:36 PM
Ah cool let me try
Dave K
04/07/2021, 9:49 PM
It’s very very slow now, but also still experiencing the same issue: every function appears valid until I run it
. Please describe your case there and vote for this issue
p
pgreze
04/08/2021, 6:17 AM
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