2

I have got following question: I have my play application lets call it PlayApp. Inside this Play application I've created subproject (in dir /MyLib inside playApp)let's call it MyLib. This MyLib project have some macro with class annotations. I want to use that annotations inside PlayApp. So I created this MyLib, I've made PlayApp dependent on MyLib. Everything works fine. This is my PlayApp/build.sbt

...
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0-M5" cross CrossVersion.full)

lazy val root = (project in file(".")).enablePlugins(PlayScala).aggregate(MyLib).dependsOn(MyLib)

lazy val MyLib = project
...

I know that PlayApp should depend on MyLib, it should be compiled in another compilation run. But I want to make jar from this MyLib project. So I did it with

sbt assembly 

in /MyLib and then I have placed jar inside /lib of my project. Everything looks fine, I can see classes compiled from MyLib.jar but I get compilation error:

Compilation error

macro annotation could not be expanded (the most common reason for that is that you need to enable the macro paradise plugin; another possibility is that you try to use macro annotation in the same compilation run that defines it)

Which is familiar error to me. This looks like play tries to compile macro in same compilation run as PlayApp. Anybody knows the solution?

EDIT:

I've found this. I double imported my macro annotation in my project class where I wanted to use it...You normally pack your library into jar, place it inside /lib in your Play App and in build.sbt you just add this compiler plugin. My error was no connected with that procedure. Double check imports which are another possibility to see this compilation error.

0 Answers0