scala如何支持这种sbtdsl语法?

kg7wmglp  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(333)

我正在浏览sbt手册,我发现您可以设置项目并从val的名称推断位置。 lazy val util = (project in file("util")) 相当于 lazy val util = project 这怎么可能?

e0bqpujr

e0bqpujr1#

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

相关问题