├── project └── build.properties ├── core └── src │ └── main │ └── scala │ └── Test.scala ├── macros └── src │ └── main │ └── scala │ └── Macros.scala └── README.md /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.11 2 | -------------------------------------------------------------------------------- /core/src/main/scala/Test.scala: -------------------------------------------------------------------------------- 1 | object Test extends App { 2 | Macros.hello 3 | } -------------------------------------------------------------------------------- /macros/src/main/scala/Macros.scala: -------------------------------------------------------------------------------- 1 | import scala.language.experimental.macros 2 | import scala.reflect.macros.blackbox.Context 3 | 4 | object Macros { 5 | def impl(c: Context) = { 6 | import c.universe._ 7 | c.Expr[Unit](q"""println("Hello World")""") 8 | } 9 | 10 | def hello: Unit = macro impl 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### An example SBT project which uses macros (Scala 2.11, SBT 0.13) 2 | 3 | To verify that everything works fine, do `sbt run`. 4 | 5 | Note that currently SBT doesn't support recompilation of macro clients if the dependencies of the macro implementation have changed - macro clients are only recompiled when the macro definition itself is: https://github.com/sbt/sbt/issues/399. 6 | 7 | Huge thanks to Paul Butcher (https://github.com/paulbutcher/ScalaMock/blob/typemacros/project/Build.scala) and Adam Warski (https://github.com/adamw/scala-macro-debug) whose SBT projects I used as prototypes for this one. 8 | --------------------------------------------------------------------------------