Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

scala

sbt

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 created a project from template. And generated project from template missed build.sbt file, but it have build.scala (which seems used for same purposes, but it is more flexible).

So what is the difference between build.sbt and build.scala?
Which is more preferred and why?

like image 873
WelcomeTo Avatar asked Aug 01 '13 16:08

WelcomeTo


People also ask

What is the difference between sbt and Scala?

If you call scala, you will get whatever scala version is installed on the path of your operating system. If you call sbt console, you get the scala version configured in the sbt build (build. sbt) with all libraries that are used in the build already on the classpath.

What is build sbt in Scala?

sbt is a popular tool for compiling, running, and testing Scala projects of any size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies or more than one code file.

What is a build sbt file?

sbt is an open-source build tool for Scala and Java projects, similar to Apache's Maven and Ant.

What does Scala sbt stand for?

Project Information Over time some have re-defined sbt to stand for “Scala Build Tool”, but we believe that isn't accurate either given it can be used to build Java-only projects.


1 Answers

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.

like image 52
Chris Martin Avatar answered Sep 19 '22 18:09

Chris Martin