Wednesday, May 24, 2017

SBT commands

http://www.scala-sbt.org/release/docs/Running.html

Here are some of the most common sbt commands. For a more complete list, see Command Line Reference.
cleanDeletes all generated files (in the target directory).
compileCompiles the main sources (in src/main/scala andsrc/main/java directories).
testCompiles and runs all tests.
consoleStarts the Scala interpreter with a classpath including the compiled sources and all dependencies. To return to sbt, type :quit, Ctrl+D (Unix), or Ctrl+Z (Windows).
run *Runs the main class for the project in the same virtual machine as sbt.
packageCreates a jar file containing the files in src/main/resources and the classes compiled from src/main/scala andsrc/main/java.
help Displays detailed help for the specified command. If no command is provided, displays brief descriptions of all commands.
reloadReloads the build definition (build.sbtproject/*.scala,project/*.sbt files). Needed if you change the build definition.

http://www.scala-sbt.org/release/docs/Basic-Def.html


In sbt shell, you can type the name of any task to execute that task. This is why typing compile runs the compile task. compile is a task key.
$ sbt
> tasks

This is a list of tasks defined for the current project.
It does not list the scopes the tasks are defined in; use the 'inspect' command for that.
Tasks produce values.  Use the 'show' command to run the task and print the resulting value.

  clean            Deletes files produced by the build, such as generated sources, compiled classes, and task caches.
  compile          Compiles sources.
  console          Starts the Scala interpreter with the project classes on the classpath.
  consoleProject   Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.
  consoleQuick     Starts the Scala interpreter with the project dependencies on the classpath.
  copyResources    Copies resources to the output directory.
  doc              Generates API documentation.
  package          Produces the main artifact, such as a binary jar.  This is typically an alias for the task that actually does the packaging.
  packageBin       Produces a main artifact, such as a binary jar.
  packageDoc       Produces a documentation artifact, such as a jar containing API documentation.
  packageSrc       Produces a source artifact, such as a jar containing sources and resources.
  publish          Publishes artifacts to a repository.
  publishLocal     Publishes artifacts to the local Ivy repository.
  publishM2        Publishes artifacts to the local Maven repository.
  run              Runs a main class, passing along arguments provided on the command line.
  runMain          Runs the main class selected by the first argument, passing the remaining arguments to the main method.
  test             Executes all tests.
  testOnly         Executes the tests provided as arguments or all tests if no arguments are provided.
  testQuick        Executes the tests that either failed before, were not run or whose transitive dependencies changed, among those provided as arguments.
  update           Resolves and optionally retrieves dependencies, producing a report.

More tasks may be viewed by increasing verbosity.  See 'help tasks'.

No comments:

Post a Comment