Compiling kotlin code without a script


#1

Hi,

I am trying to compile kotlin code as a string argument in java. But I couldn’t find any compile function to do so.


#2

There isn’t one. Setting up the Kotlin compiler is fairly complicated, and at this time it’s not encapsulated into a single function that you can call.


#3

Thanks Yole. Also I have another question. Should I create a new message for it?


#4

actually im using the compiler to generate classes at runtime.
you add
compile ("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
to your build file and call

                "-d", targetJar))```
but it means u have to write your code into a file, cant give it as a string.