What is the difference between build.sbt and build.scala?

前端 未结 3 1574
[愿得一人]
[愿得一人] 2020-12-12 13:17

I started to learn Scala and almost in every tutorial I see a build.sbt file which describes project settings. But now I have installed giter8 and

3条回答
  •  粉色の甜心
    2020-12-12 13:53

    To give a brief example, this build.sbt:

    name := "hello"
    
    version := "1.0"
    

    is a shorthand notation roughly equivalent to this project/Build.scala:

    import sbt._
    import Keys._
    
    object Build extends Build {
      lazy val root = Project(id = "root", base = file(".")).settings(
        name := "hello",
        version := "1.0"      
      )
    }
    

    The .sbt file can also include vals, lazy vals, and defs (but not objects and classes).

    See the SBT document called ".scala build definition", particularly the section "Relating build.sbt to Build.scala".

    Consider a .scala build definition if you're doing something complicated where you want the full expressiveness of Scala.

提交回复
热议问题