How does scala support this sbt DSL syntax?

Viewed 65

I was looking through the sbt manual and I see that you can set projects and infer the location from the name of the val.

lazy val util = (project in file("util")) is equivalent to lazy val util = project How is this possible?

1 Answers

The macro

/**
 * Creates a new Project.  This is a macro that expects to be assigned directly to a val.
 * The name of the val is used as the project ID and the name of the base directory of the project.
 */
def project: Project = macro Project.projectMacroImpl

expands

lazy val util = project

to

Project.apply("util", new File("util"))

To see what sbt macros expand to create project/build.sbt file with

scalacOptions ++= Seq("-Ymacro-debug-lite")
Related