I figured out that I need to add `implicitReceiver...
# scripting
a
I figured out that I need to add
implicitReceivers
both in compilation configuration and evaluation configuration, but now I have
java.lang.IllegalArgumentException: Unknown key Key(baseClass)
n
when i tried that .. i could not get it to work.. so what i instead did was make my script class extend the Builder,
WorkspaceBuilder
in your case and passed the constructor args
for just a single implicit receiver this works better and idea deals with it very well
tbf, i did not try to get implicitReceivers working for very long
a
I guess that I can do that as workaround. But for that I need the
Builder
to be open which is not always convenient.
i
Script compilation needs
baseClass
- a superclass for script code generation - in the compilation configuration. (Maybe this is a non-necessary limitation and we’ll drop it in the future) It should be either put there manually, or, preferably, by annotating base class with a
@KotlinScript
and then creating a(n extendable) configuration from it. See e.g. here - https://github.com/JetBrains/kotlin/blob/1.3.20/libraries/examples/scripting/jvm-simple-script/host/src/org/jetbrains/kotlin/script/examples/jvm/simple/host/host.kt#L19
a
I've tried to use
Any
as a base class. The script compiles, but does not affect the receiver state.
i
That’s quite strange. If you have a repro, please let me have a look.
I am not sure that the problem is with receiver, because it does not display the message from script
OK, I think I see the problem now, I assumed that all diagnostic messages come with throwables, but they are not. It says it can't see receiver
i
Ah, yes. The proper docs/tutorials are still missing, sorry about it. So do you know why it can’t see the receiver too?
a
It seems that only JDK classpath is passed to the script context. My classes are missing
Fixed it! I needed to use
dependenciesFromCurrentContext(wholeClasspath = true)
. Thanks a lot
i
You figured out almost everything yourself, so nothing really to thank about. 🙂 Congrats!
a
I will finish the debug and post a reference to the channel. I needed your word that it should work 🙂