Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Simple Project SBT 0.10.X

Tags:

scala

sbt

(This is a follow up to sbt not creating projects correctly. The question wasn't answered.)


Basically, that question says "I don't know how to create a project under the new sbt. With the old one, I just ran sbt in a new folder and there was a guided wizard that led me through the setup."

The accepted answer does not explain how to create a new project, it just points to the documentation, which also doesn't explicitly say how to create a new project -- only how to write a build.sbt file.

So I tried first writing a build.sbt and then running sbt in the directory with the build.sbt file, but I still don't see a src directory to work with.

Could someone post a simple step-by-step (I'm assuming there are like 3 steps at most) guiding how to create a new project under sbt 0.10.X?

like image 624
dsg Avatar asked Sep 12 '11 18:09

dsg


People also ask

How do I create a Scala project in sbt?

Delegate a Scala project build to sbtPress Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.

What is a sbt project?

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.

How run sbt project from command line?

sbt shell has a command prompt (with tab completion and history!). To compile again, press up arrow and then enter. To run your program, type run . To leave sbt shell, type exit or use Ctrl+D (Unix) or Ctrl+Z (Windows).


1 Answers

I found the answer I was looking for at this webpage: Scala 2.9.1, sbt 0.10 and ScalaTest step-by-step.

The high-level steps are:

  1. mkdir my_project make a folder for your project
  2. Create a simple my_project/build.sbt file, e.g.:

    name := "A Project"  version := "0.1"  scalaVersion := "2.9.1"  libraryDependencies ++= Seq(   "org.scalatest" %% "scalatest" % "1.6.1" % "test" ) 
  3. Create a file my_project/src/main/scala/HelloWorld.scala, where you create all the directories you need as you go (e.g. create the directory structure src/main/scala/)

    object Main extends App { Console.println("Hello World!") }

  4. Execute your sbt commands: e.g. sbt run

like image 107
dsg Avatar answered Oct 27 '22 00:10

dsg