I've watched the <talk> of Oliveira to the Kotlin ...
# scripting
e
I've watched the

talk

of Oliveira to the Kotlin Conf and I wonder if I may be able to implement something Gradle-like, where you have a
plugins
block which gets evaluated and based on its content, specific code would be generated and made available to the rest of the script. In Gradle you have to hit refresh in the Gradle window, in order to trigger this mechanism, but what about in a classic script instead?
j
I think they have its own compiler plugin for that
e
may I ask what suggests you that?
j
What you mean?
e
why do you think they use a compiler plugin
e
Not a compiler plugin but they parse the source code “manually” (not with regex or anything but via a kotlin lexer)
i
There is a callback mechanism in the scripting API (
refineConfigurationBeforeParsing
property in the configuration) that would allow you to "intercept" the compilation in order to process your variant of the
plugins
block and supply the results (most importantly - new dependencies) to the compilation of the original script. But there are no means yet that would help you to process the block, you'll need to parse the script on your own. I do not recommend using compiler internals for that, like the lexer, while it may not be available for you in the future.
👍🏾 1
👍 1