SBT/build.sbt: One percent symbol or multiple percent symbol for Java and Scala dependencies?

As a brief note today, when you’re using SBT and its build.sbt file with Scala projects:

  • use %% in library dependencies when referring to Scala-specific libraries, and
  • use only one % character when referring to other JVM dependencies, like Java dependencies/libraries

Here are some examples of this syntax:

name := "StaticDrupal"
version := "1.51"
scalaVersion := "2.12.12"

lazy val root = (project in file(".")).enablePlugins(SbtTwirl)

libraryDependencies ++= Seq(
    "com.h2database"     %  "h2"                   % "1.4.196",   // java
    "org.scalikejdbc"    %% "scalikejdbc"          % "3.1.0",     // scala
    "org.scalikejdbc"    %% "scalikejdbc-config"   % "3.1.0",
    "ch.qos.logback"     %  "logback-classic"      % "1.2.3",
    "mysql"              %  "mysql-connector-java" % "8.0.19",
    "com.typesafe"       %  "config"               % "1.4.0",
    "org.scalactic"      %% "scalactic"            % "3.1.1",
    "org.scalatest"      %% "scalatest"            % "3.1.1"  % "test",
    "org.jsoup"          %  "jsoup"                % "1.11.2",
    "org.apache.commons" %  "commons-text"         % "1.8"
)

Compile / mainClass := Some("static_drupal.GenRootIndexPages")
// mainClass := Some("Main")

scalacOptions += "-deprecation"

In that example build.sbt file, libraries like JSoup and Apache Commons are Java libraries, so I refer to them with one % character, and libraries/dependencies like ScalaTest are Scala libraries, so I use %%.

Note that I write much more about this in these tutorials: