I wanted to ask if it’s possible to compile Kotlin code if it’s represented as a String.
This should happen at runtime in a JUnit test.
Suppose I have a test code snippet and I just want to check whether it’s valid Kotlin code or not.
Is there any build-in mechanism to do this?
In Java this is possible with the following code by getting the Java compiler from the ToolProvider and compile a file for instance.
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); compiler.run(null, null, null, javaFile.getAbsolutePath());