scalamavenaspectjcompile-time-weaving

AspectJ compile-time weaving and Scala


Is it possible to have a Scala Maven project and weave AspectJ aspects at compile-time within the Scala classes?

I've been able to get load-time weaving to work but so far no success with compile-time.

The aspects are simply not woven into the Scala classes. From what I understand, compile-time weaving requires a specific Java compiler (AspectJ Compiler aka ajc). It is my understanding that ajc cannot compile Scala.

Is there an ajc equivalent for Scala? Or perhaps another way to get compile-time weaving to work with Scala?


Solution

  • How about using AJC's -inpath switch? It accepts .class files in directories or JARs and weaves into them. Your Scala compiles to .class files, so that ought to work. No doubt you have the AJC docs, but here's a link.