Question

According to this post In order to create a Scala compiler plugin, one needs to compile the plugin into a jar, and then either specify the reference to the the jar as command line arguments, or place the jar in $SCALA_HOME/misc/scala-devel/plugins.

I need to call the compiler in runtime, with the scala compiler API (scala.tools.nsc). Is it possible to Is it possible to the compiler plugin dynamically in runtime, before calling the compiler?

Was it helpful?

Solution

I am not entirely sure what you mean by loading it in runtime, but I assume you intend to also call the compiler at runtime then and supply it with that plugin.

In that case, yes this is possible. You can take a look at RunPlugin.scala from the alacs test suite for an example. The project's not really active anymore, but it provided compiler plugins for additional checks, which are also tested via a test suite involving the above class for runtime compilation with selected plugins.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top