1

Mill documentation says

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

So this is possible in mill v0.9.9

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

and this

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

but these do not compile:

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") : _* )

Is it somehow possible to create def sourceRoots: Sources = T.sources ... from a seq of paths?

user4955663
  • 1,039
  • 2
  • 13
  • 21

1 Answers1

0

There are two overloads for T.sources construction. One accepts os.Paths, the other one accepts a Seq[mill.api.PathRef].

To create a T.sources from a Seq[os.Path], do the following:

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

def sourceRoots = T.sources { paths.map(p => PathRef(p)) }
Tobias Roeser
  • 431
  • 2
  • 8
  • Thank you! So it's the overload def sources(values: Result[Seq[PathRef]]). Is there an implicit conversion from Seq[PathRef] to Result[Seq[PathRef]] or how is that achieved? – user4955663 Aug 31 '21 at 09:46
  • Yes, in companion `object Result` there is an `implicit def create[T](t: => T): Result[T]` conversion. – Tobias Roeser Sep 01 '21 at 08:24