How to specify logback as project dependency? - sbt

I am using sbt for an Akka project. I want to redirect the output of the logger. Therefore I'd like to use logback.
What do I have to add to build.sbt to manage the library dependency for logback?

Add the following to build.sbt:
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3"

Related

Unable to download dependencies in SBT

I am trying to add below dependency but it is never resolved.
libraryDependencies += "com.typesafe" % "config" % "1.3.2"
Below are the versions used
scalaVersion := "2.12.7"
sbt.version = 1.2.4
Try adding resolver in plugin.sbt as
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

Modify libraryDependcies inside of SBT

I use SBT / Console as a prototyping tool and therefore don't want to start with a pre-defined build.sbt file.
What I want to do is to run the sbt tool and then modify the libraryDependencies setting. then run console and go and use my newly imported library. If I need something more. I can exit the console and import more stuff and then come back in the console.
is this possible? or should I always start with a predefined build.sbt file?
set libraryDependencies += group % art % version
I understand ammonite is good at this as well

sbt - copy managed libraries to lib

How can I copy managed libraries to a specific folder with Scala Build Tool?
For example:
All the jars from this managed library, would be put in 'project/lib'
libraryDependencies += "com.miglayout" % "miglayout-swt" % "4.2"
I found the solution. Pretty simple actually.
Add the following to build.sbt
This will copy the jars to project/lib_managed/jars//*.jar
retrieveManaged := true
I'm not sure about how to specify a specific folder, but this is good enough to get the jars under the project folder.

How to "re-run with -deprecation for details" in sbt?

When I compile Scala code, by running sbt compile, SBT says:
$ sbt compile
...
[warn] there were 5 deprecation warnings; re-run with -deprecation for details
...
How do I do that? (From within SBT?)
sbt shell
While in sbt shell (if you don't want to change your build.sbt):
$ sbt
> set ThisBuild/scalacOptions ++= Seq("-unchecked", "-deprecation")
> compile
> exit
Due to in ThisBuild, set applies the settings to all sub-projects, as well.
Command Line
You could also run the above as a single command on command line.
sbt '; set ThisBuild/scalacOptions ++= Seq("-unchecked", "-deprecation") ; compile'
The trick is to use ; (semicolons) to separate commands and ' (ticks) to include all ;-separated commands as a single argument to sbt.
sbt < 1.x
Instead of ThisBuild/scalacOptions use scalacOptions in ThisBuild
scalacOptions := Seq("-unchecked", "-deprecation")
Add this setting to your build.sbt, and, if you have a multi-module project, add it to every project's settings.
As times flows new solutions are emerged. So, now you could re-run the scala compiler without issuing entire project rebuild.
You need to install ensime-sbt plugin:
addSbtPlugin("org.ensime" % "sbt-ensime" % "1.0.0")
After that you could use the ensimeCompileOnly task to compile single file. SBT allows per tasks settings configuration, so you could change for that tasks only:
set scalacOptions in (Compile, EnsimeKeys.ensimeCompileOnly) += "-deprecation"
ensimeCompileOnly src/main/scala/MyFile.scala

Simple way to add jar URL as dependency in sbt

Is there any way to get sbt (0.10) to declare a jar at some URL (http://foo.com/bar-1.1.jar) as a library dependency?
You can specify an explicit url for a jar. If you use the basic configuration just include it like follows
libraryDependencies += "slinky" % "slinky" % "2.1" from "http://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar"
As stated in the sbt wiki on GitHub the url is used as a fallback in case the artifact isn't resolved via ivy. For more details see paragraph Explicit URL

Resources