embedded scala compiler with nonstandard classloader

I would like to embed scala compiler (utilize IMain class) in spring-boot packed application. But I have no success, it seems that compiler is unable to see libraries (even the namespace) from my application. I have provided my context classloader to compiler but what I know, it is not sufficient because compiler needs direct access to byte code. Spring-boot jar have my own classes in /BOOT-INF/classes directory and library jars in BOOT-INF/lib (not exploded).

I would be nice to have some easy way to tell compiler, how to find the needed bytecode but I don’t know where to start. The compiler code seems to me too much complicated.

I have the exact same situation. I can start up a Spring Boot instance from a Java main class, but would like to do it from a Scala main class.,

If I understand you right, you want to have classes used by your application provided as dependencies for compiling. In this case, you should use the reflection compiler (scala.tools.reflect.ReflectGlobal). Make sure all classes the compiler needs to see are actually loaded by using them in the application before invoking the reflection compiler.

Seems working, super! Thank you, I would never findout this :slight_smile: