sbt



New Project create a directory and cd there
#!/bin/sh
mkdir -p src/{main,test}/{java,resources,scala} lib project target

# create an initial build.sbt file
echo 'name := "MyProject"

version := "1.0"

scalaVersion := "2.11.5" ' > build.sbt
curl https://www.gitignore.io/api/scala,sbt,eclipse,java > .gitignore
echo 'object Main extends App {
    Console.println("Hello World!")
 }' > src/main/scala/HelloWorld.scala
sbt compile   
sbt run
echo 'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "3.0.0")' > project/plugins.sbt
sbt eclipse
ls -a


To check version
$ sbt sbt-version   


Example run commands
$ sbt -mem 50000 'run-main edu.ufl.cise.pipeline.Pipeline'
$ sbt -J-Xmx50g  'run-main edu.ufl.cise.CorpusBatchProcessor'
$ env JAVA_OPTS="-Xmx20G -Dcom.sun.management.jmxremote.port=3333 -Dcom.sun.management.jmxremote.ssl=false  -Dcom.sun.management.jmxremote.authenticate=false" sbt 'run-main edu.ufl.cise.EmbededFaucet' 
$ env JAVA_OPTS="-Xmx10g" sbt 'run-main edu.ufl.cise.EmbededFaucet'
$ sbt run edu.ufl.cise.Faucet
$ sbt clean; sbt compile; sbt eclipse; sbt package;
$ sbt
> clean
> compile
> test
> run   //If your project has an object with a main method (or an object extending the trait App), then you can run the code in sbt easily by typingrun. In case sbt finds multiple main methods, it will ask you which one you’d like to execute.
> console  //to start the Scala interpreter inside sbt using the console task. The interpreter (also called REPL, for “read-eval-print loop”) is useful for trying out snippets of Scala code. to quit the interpreter and get back to sbt, type ctrl-d.


Find jar dependecies for sbt integration here: http://mvnrepository.com/

Prepare for eclipse structure
$ sbt eclipse       

sbt run test in eclipse

You can easily execute the test suites directly inside eclipse. Simply navigate to source file of the test suite in src/test/scala, right-click on it and select “Run As” - “JUnit Test”.


ScalaTest
add
libraryDependencies += "org.scalatest" %% "scalatest" % "1.6.1" % "test"
to build.sbt

Install sbt

Download tgzip file from http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html  

Add bin directory to path

in ~/.bashrc append to end
SBT_HOME=/home/morteza/zproject/packages/sbt
export SBT_HOME

PATH=$PATH:$SBT_HOME/bin
export PATH


OR export PATH=/PATH/TO/YOUR/sbt/bin:$PATH

$ source ~/.bashrc

check sbt version

$ sbt sbt-version



Comments