Request Reference to 'Current' Working self-contai...
# scripting
d
Request Reference to 'Current' Working self-contained sample of basic JVM Scripting Host build I have tried, unsuccessfully, many times over the last 2 years to put together a very 'basic' JVM Scripting 'host' that can do a 'Eval' of a .kts file or script body (and parameters). I was able to get the JSR223 samples to work (which I have working now) but they are not ideal and have a lot of dependencies and resource use which I've learned recently (From this list) that are not issues with the native scripting host. The problem I find is that I cannot locate a 'current working example' anywhere -- Ive found many that probably worked at some time but by the time I find them them they do not, Or examples , such as from the intellij and kotlin distributions that might work -- -- if only I could decipher the chain of dependencies in the whole project -- And many of those simply didnt work even when built directly within the project cleanly cloned from github. I know its a moving target, and that dependencies are either not shipped or expected to be replaced by others or 'internal only' or some other combination of magic - all for good reasons. Or that the code-in-question 'Works For Me' where 'Me' is an internal developer or someone with a dependency resolver that I cannot locate or reverse engineer. At this point in the 'Kotlin Scripting Story' surely theirs a basic stable example to use ? Probably LOTS -- but which one is valid right now ? Any suggestions welcome. (And yes I've RTFM's every article, blog, KEEP, reference etc I can find -- without locating this magic bean)
1
i
Repeating my answer in another thread - the simplest examples are located in the Kotlin repo - https://github.com/JetBrains/kotlin/tree/master/libraries/examples/scripting, and since they are part of the CI - they are kept in synch with the API all the time. To run them independently from kotlin build you’ll need to tweak build files a bit - switch to external dependencies for
kotlin-
libs (they are all part of the kotlin release and available on maven central) and setup sourcesets directly without using helpers. But that shouldn’t bee too difficult, I guess. We know that the docs/samples/tutorials are missing for scripting, we are working on it. But the main reason for that is that this stuff is still considered experimental and unstable.
d
THis last bit has been the most challenging --- exactly what the dependencies are, its entirely obtuse how to derive that from the source tree I will take another pass at it -- and if you dont mind, will post where I get stuck. If I can (will it break any copyright or other issues?) -- maybe Ill post a standalone version that can be built on its own I understand the rationale -- but encourage JetBrains to remember that 'we' (outside of JB) dont have the domain knowledge to always be able to figure out 'the obvious' and hence are of little value in assisting JBs with feedback to help bring experimental to production ready -- if we cant figure out how to build by itself even an experimental sample
Example: of 'the obvious' which -- IMHO -- is precisely the opposite: `To run them independently from kotlin build you’ll need to tweak build files a bit - switch to external dependencies for
kotlin-
libs (they are all part of the kotlin release and available on maven central) and setup sourcesets directly without using helpers. *But that shouldn’t bee too difficult, I guess.*` This last sentence -- for me atleast - could be realistically rewrite as "But you.ll never be able to figure it out on your own no matter how hard you try" With a secondary difficult of figuring out which of the many examples in different places correspond to the current path/direction, what the exact version of IntelliJ, kotlin, kotlin plugin etc are needed, which repo of many hosts them, and which repo will they likely move into tomorrow You've answered the first one THANK YOU !!!! That gives me enough faith that whatever effort put in will at least be in the right direction , not dead end with "Oh by the way this isnt how it actually works NOW"
Will conclude with , besides an other "THank you!" -- If your in the position of choosing where to put what little resources/time you have been allocated to 'documentation' --> My personal opinion (from almost 40 years of SW development) Given the choice of only 1 -- I would BY FAR prefer to have • A simple standalone working example of a minimum viable 'hello world' complexity program VS ANY amount of documentation or samples that only work within a huge internal build system Both of course is better -- But the chances of being able to figure out how to get something to work -- and then improve on that are far greater with the former -- to the point that the later is often unnecessary Whereas visa-versa -- a total crap-shot with minimal odds of success
i
Thank you for your feedback. Yes, you’re right, of course, simple example worth many pages of docs. We’ll see what we can do about it in the near future.