如何从 mill build.sc 文件中的 Seq[Path] 创建源?

How to create Sources from a Seq[Path] in mill build.sc file?

米尔 documentation

Sources are defined using T.sources {…​}, taking one-or-more os.Paths as arguments. A Source is a subclass of Target[Seq[PathRef]]

所以这在 mill v0.9.9 中是可能的

def sourceRoots: Sources = T.sources { os.pwd / "src" }

还有这个

def sourceRoots: Sources = T.sources ( os.pwd / "src", os.pwd / "foobar" ) 

但是这些不编译:

def sourceRoots = T.sources { os.pwd / "src", os.pwd / "foobar" }
def sourceRoots = T.sources { Seq(os.pwd / "src", os.pwd / "foobar") }
def sourceRoots = T.sources { Seq(os.pwd / "src", os.pwd / "foobar") : _* }
def sourceRoots = T.sources ( Seq(os.pwd / "src", os.pwd / "foobar") )
def sourceRoots = T.sources ( Seq(os.pwd / "src", os.pwd / "foobar") : _* )

是否有可能从一系列路径创建 def sourceRoots: Sources = T.sources ...

T.sources 构造有两个重载。一个接受 os.Paths,另一个接受 Seq[mill.api.PathRef].

要从 Seq[os.Path] 创建 T.sources,请执行以下操作:

val paths = Seq(millSourcePath / "src", millSourcePath / "src-jvm")

def sourceRoots = T.sources { paths.map(p => PathRef(p)) }