scala 如何支持这种 sbt DSL 语法?

Tho*_*mas 2 scala sbt

我正在查看sbt 手册,我看到您可以设置项目并从 val 的名称推断位置。

lazy val util = (project in file("util")) 相当于 lazy val util = project 这怎么可能?

Mar*_*lic 5

/**
 * 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
Run Code Online (Sandbox Code Playgroud)

扩大

lazy val util = project
Run Code Online (Sandbox Code Playgroud)

Project.apply("util", new File("util"))
Run Code Online (Sandbox Code Playgroud)

查看 sbt 宏扩展以创建project/build.sbt文件的内容

scalacOptions ++= Seq("-Ymacro-debug-lite")
Run Code Online (Sandbox Code Playgroud)