 Following are commonly used commands. Here is a more complete list.
- assembly
- Build executable jar with all dependencies (using sbt-assembly), named target/YourProjectName-assembly-X.Y.jar. If your project has only one main(), and you have specified in in the project build.sbt with the mainClass statement, run it like this:
java -jar target/ProjectName-assembly-X.Y.jar
Otherwise, specify the class that defines the main()that you want to run like this:
java -cp target/ProjectName-assembly-X.Y.jar com.domain.MyMainClass
- clean
- Deletes files produced by the build, such as generated sources, compiled classes, and task caches. It does not remove all compiled artifacts. Here is deeper clean:
find . -name target -type d -exec rm -rf {} \;
- compile
- Compiles sources; automatically runs update first.
- ~compile
- Continuously compiles sources.
- console
- Starts the Scala interpreter with the project classes on the classpath.
- dist
- Requires akka-sbt-plugin. Builds an Akka kernel project as documented here. If you have a script to run the project, you can conditionally launch it as follows:
sbt dist && run
Here is a sample run script:
#!/bin/bash
target/publisher-dist/bin/start com.x.y.MyKernel
- doc
- Generates Scaladoc for src/main into target/api/index.html. See also test:doc.
- full-classpath
- The exported classpath, consisting of build products and unmanaged and managed, internal and external dependencies.
sbt "show full-classpath"
- offline
- Configures SBT to work without a network connection where possible.
- package
- Produces the main artifact, such as a binary jar. (e.g. into target/scala-2.9.1/hanuman_2.9.1-0.1.jar)
- project
- In a multi-module project, switch to the specified module. The project sub-command only persists for the life of the sbt command, so if used on a command-line it must be followed by another sub-command:
sbt "project myproject" publish-local
Here the project sub-command is used to republish the module locally each time the source changes:
sbt "project myproject" ~publish-local
The project sub-command can also be used in an sbt session:
sbt
[info] Loading global plugins from C:\Users\Mike Slinn\.sbt\plugins
[info] Loading project definition from E:\work\x\y\project
[info] Set current project to Some Project(in build file:/E:/work/x/y/)
common:master> project myproject
[info] Set current project to myproject (in build file:/E:/work/x/y/)
myproject:master> publish-local
...
- publish
- Publishes artifacts to a repository. After running this sub-command, be sure to remove the results of any prior publish-local sub-commands, which are stored under ~/.ivy2/local. If you do not do this, the jars created by publish-local will be used instead of the published jars.
- publish-local
- Compiles and publishes artifacts to ~/.ivy2/local.
- ~publish-local
- Continuously compiles and publishes artifacts to ~/.ivy2/local.
- run
- Runs a main class. Currently does not detect Java classes with static void main() methods.
- run-main
- Runs a main class, passing along arguments provided on the command line. For example:
sbt 'run-main com.micronautics.akka.dispatch.futureScala.Zip'
Windows does not understand single quotes, so you must use double quotes with Windows:
sbt "run-main com.micronautics.akka.dispatch.futureScala.Zip"
- test
- Executes all tests that are not marked with ignore.
- test-only
- Executes tests in one test class. For example:
sbt 'test-only com.blah.MyTest'
Windows does not understand single quotes, so you must use double quotes with Windows:
sbt "test-only com.blah.MyTest"
- help command*
- Displays help message or prints detailed help on requested commands.
- show
- run a task and print the resulting value (not required for all tasks, like compile)
sbt 'show homepage'
Windows does not understand single quotes, so you must use double quotes with Windows:
sbt "show homepage"
- tasks
- Displays the tasks defined for the current project.
- start-script
- Generate a script called target/start for an SBT project. The script runs the project in-place, without having to build a package first or even to run SBT. Requires xsbt-start-script-plugin.
- test:doc
- Generates Scaladoc for src/test to target/test-api/index.html. Does not include or link to Scaladoc for src/main, unfortunately.
- update-classifiers
- Download sources and javadoc for all dependencies
- update-sbt-classifiers
- Download source jars for sbt and plugins to ~/.ivy2/cache subdirectories; sbt source jars will be under ~/.ivy2/cache/org.scala-sbt
|
|