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

How does scala support this sbt DSL syntax?

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

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

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

扩展

lazy val util = project

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

查看哪些 sbt 宏扩展以使用

创建 project/build.sbt 文件
scalacOptions ++= Seq("-Ymacro-debug-lite")