Questions tagged [sbt]

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

  • Fast and unintrusive to build simple projects.
  • Supports multiple projects/modules, external projects and other advanced setups.
  • Configuration, customization, and extension are done in Scala.
  • Dependency management support: inline declarations, external Ivy or Maven configuration files, and manual library management.
  • Supports mixed Scala/Java projects, packages jars, generates documentation with scaladoc.
  • Plugin framework for customized integrations (i.e. web app servers, IDEs, ORMs).
  • Supports testing with ScalaCheck, specs, and ScalaTest (JUnit is supported by a plugin).
  • Continuous compilation and testing with triggered execution.
  • Accurate recompilation is done using information extracted from the compiler.
  • Starts the Scala REPL with project classes and dependencies on the classpath.
  • Parallel task execution, including parallel test execution.

Official repository at GitHub

Official website

Stack Overflow sbt Tutorial

  1. General
  2. Dependency management
  3. Multiproject builds with .sbt files
  4. Publishing
  5. Cross-building
  6. Logging
  7. Using plugins
  8. sbt-assembly
  9. Developing tasks
  10. Developing plugins
  11. Developing commands
  12. Outside sbt
9905 questions
41
votes
4 answers

Use SBT To Build Pure Java Project

Historically I have used Ant+Ivy or Maven for building my Java projects. I'm now looking at non-xml based solutions. Gradle can compile, jar and publish my project with few issues. Can I do the same with SBT? If so, can you provide a simple example…
opticyclic
  • 7,412
  • 12
  • 81
  • 155
41
votes
7 answers

Strange sbt bug where I cannot import sbt project due to keys colliding with themselves

After changing my build.sbt file in IntelliJ, I get this strange error report where it appears that "keys" (I don't know what these keys even are) are colliding with themselves. Researching this error message only finds github pull requests where…
K. M
  • 867
  • 1
  • 8
  • 17
41
votes
4 answers

How to add "provided" dependencies back to run/test tasks' classpath?

Here's an example build.sbt: import AssemblyKeys._ assemblySettings buildInfoSettings net.virtualvoid.sbt.graph.Plugin.graphSettings name := "scala-app-template" version := "0.1" scalaVersion := "2.9.3" val FunnyRuntime =…
user2785627
  • 411
  • 1
  • 4
  • 3
41
votes
6 answers

Best practices for IntelliJ IDEA 9 + Maven + Version control

The project is using Maven so the POM files are the main sources of project info. There are some useful settings in the project files which would be nice to keep. OTOH IDEA seems to create too many redundant changes in the project file structure…
Sasha O
  • 3,710
  • 2
  • 35
  • 45
41
votes
3 answers

How to support multiple Scala versions in a library

I have a fairly normal Scala project currently being built using Maven. I would like to support both Scala 2.9.x and the forthcoming 2.10, which is not binary or source compatible. I am willing to entertain converting to SBT if necessary, but I have…
Christopher Currie
  • 3,025
  • 1
  • 29
  • 40
40
votes
9 answers

Create Simple Project SBT 0.10.X

(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…
dsg
  • 12,924
  • 21
  • 67
  • 111
40
votes
2 answers

How to execute tests that match a regular expression only?

In sbt 0.10.1, I frequently use test-only to narrow down the number of my tests. sbt> test-only com.example.MySpec However, I want to narrow down such that I only run tests whose name/description matches a regular expression. Is there some syntax…
tobym
  • 1,354
  • 1
  • 10
  • 11
40
votes
10 answers

Could not find or load main class in scala in intellij IDE

I have searched for this error, but the answers were for Java, but my case is Scala. I am trying to run this project in IntelliJ IDE sentimenAnalysis, but it throws an error. This is also the structure of the project. Class Not found Update 1…
sariii
  • 2,020
  • 6
  • 29
  • 57
40
votes
9 answers

Compilation failed: error while loading AnnotatedElement, ConcurrentMap, CharSequence from Java 8 under Scala 2.10?

I'm using the following: Scala 2.10.4 Scalatra 2.2.2 sbt 0.13.0 java 1.8.0 casbah 2.7.2 scalatra-sbt 0.3.5 I'm frequently running into this error: 21:32:00.836 [qtp1687101938-55] ERROR o.fusesource.scalate.TemplateEngine - Compilation…
jnfr
  • 941
  • 3
  • 9
  • 21
39
votes
1 answer

How to run sbt multiple command in interactive mode as one command?

I want to refine sbt assembly/package operation by combine two step to one. The two step is: $ sbt > project XXX .... > assembly Ctrl + c to exit Besides, assembly is a task form fat jar sbt plugin. I have attempt with sbt project analysis assembly…
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
39
votes
2 answers

How to make "test" classes available in the "it" (integration test) configuration?

I would like to share a helper trait between my "test" and "it" configurations in SBT, but I have not figured out how. Here is a minimal example: project/Build.scala import sbt._ import Keys._ object MyBuild extends Build { val scalaTest =…
Rob Starling
  • 3,868
  • 3
  • 23
  • 40
38
votes
9 answers

How to disable package and publish tasks for root aggregate module in multi-module build?

I have a multiproject SBT project, which looks like the example on SBT doc: import sbt._ import Keys._ object HelloBuild extends Build { lazy val root = Project(id = "hello", base = file(".")) aggregate(foo, bar) lazy…
paradigmatic
  • 40,153
  • 18
  • 88
  • 147
38
votes
1 answer

How to define maven test-jar dependency in sbt

I have the following maven dependency org.apache.hbase hbase 0.90.4 test-jar test I know how…
Arnon Rotem-Gal-Oz
  • 25,469
  • 3
  • 45
  • 68
38
votes
3 answers

SBT to Maven Converter

Since most IDEs are only able to import Maven projects, I'd like to generate a POM.xml from an SBT managed project, is there a better way to do it?
Sawyer
  • 15,581
  • 27
  • 88
  • 124
38
votes
1 answer

How to force a specific version of dependency?

A dependency bar depends on foo 1.2.3, but that version of foo has a bug and I need to use version 1.2.2. I can do that with force(). libraryDependencies += "foo" %% "foo" % "1.2.2" force() That method is not recommended by the docs: Forcing a…
Paul Draper
  • 78,542
  • 46
  • 206
  • 285