https://kotlinlang.org logo
#scripting
Title
# scripting
l

laht

01/26/2021, 8:58 AM
any idea how I can compile a kotlin script using API only? I already collect all the script dependencies using maven and want to package the script into a fat jar. I only need to compile the script itself so I can throw it into a Jar.
Edit: This seemed awfully similar to the above comment, but without the dependson. I handle that myself. I only need to compile the script to .class. Annotations have been stripped from the script to be compiled
n

Nikky

01/26/2021, 11:46 AM
iirc there was some code for caching that saved the .class files in a folder.. if you can figure out how to turn it into a class file with that you just need to zip that up and add a manifest but.. i have not touched scripting for a while so i am not sure if that caching thing works the same way or even .. still exists
below that there is something called
TestCompiledScriptJarsCache
too
l

laht

02/01/2021, 10:15 AM
thanks, using the code above I'm able to get class files. However, it results in a single .class with a parent Script class. I was hoping to get individual .class files. I was planning to load the class defined in the script using JNI, and the Jar should look the same to the importing code as code written in regular Java/Kotlin