Scala seems like a good language to me but SBT turned me away. mill seems far more reasonable but some things remain unclear to me about it. The mill documentation leaves a number of things unstated and even after giving myself a little exposure to Maven and Gradle to see what precedents might be there I’m still confused.
Let’s start with the very basic beginner example. Here is the build.sc
:
// build.sc
import mill._, scalalib._
object foo extends ScalaModule{
def scalaVersion = "2.13.2"
}
OK, simple enough. And it follows that the file is in foo/src/
. But how does it know to use Example.scala
? For reference, here it is:
package foo
object Example{
def main(args: Array[String]): Unit = {
println("Hello World")
}
}
Granted, it’s the only file in this directory in this example. But I extended it by adding another file, defining a trivial class in it, importing it into Example.scala
, and making use of it in main
. How does mill foo.run
know how to use main
in Example.scala
? I assume it scans through every relevant Scala file until it finds one with a singleton class that implements main
. Is that not so?
The next example comes from a book by the author of mill, Hands-On Scala Programming. This book isn’t open source and I understand that not everyone is going to have that, so I’ll reproduce what I think is relevant here and if anything further is needed, I’ll give that too. Here is the build.sc
:
import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.13.2"
object test extends Tests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.7.4")
def testFrameworks = Seq("utest.runner.framework")
}
}
This is also pretty straightforward but ivyDeps
stands out to me. Apache Ivy, as I understand it, is a dependency management system devised for Apache Ant so what is the significance of ivyDeps
here? Does it mean that dependencies are specified using the format of Ivy?
I think my last issue here is tests. There is one test file, foo/test/src/ExampleTests.scala
. Here are the contents:
package foo
import utest._
object ExampleTests extends TestSuite {
def tests = Tests {
test("hello") {
val result = Example.hello()
assert(result == "Hello world")
result
}
}
}
How does mill know to use this file? Is it because the singleton object has the same name as the one in foo/src
with “Tests” appended? I’m not sure what the convention is here.
I think that’s all for now.