Compile script with kotlin daemon for future use

I’m using kotlin script to provide test data for my tests. The problem is the first compilation, when kotlin compiler needs to load all it’s stuff, which may take up to 7 secs on my weak laptop. It doesn’t really matter on CI, but running tests locally is pain.

So I want to use kotlin compiler daemon, to save time on first test launch.

I managed to get kotlin compiler daemon up and running, and kotlin compiler client to use that daemon for compilations.

The problem I facing is java.lang.IllegalArgumentException: Cannot find metadata for script error, when trying to invoke script’s compiled class main method. See example. I also noted, that Hello world part of my script is executed, at the constructor call.

How may I resolve this?
What’s in metadata?
Can kotlin compiler be used in that way, or I was just lucky something worked?