scala如何支持这种sbtDSL语法?

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

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

回答

该宏

/**
 * 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")


以上是scala如何支持这种sbtDSL语法?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>