In SBT it is possible to automatically recompile and reload a web app when a source file is changed by using the following command:
~ container:reload /
The first command starts the web app container the second command watches for source file changes and reloads the web app container.
Seriously? Unsupported major.minor version 51.0 when compiling a Scalatra project? The complete error is “Caused by: java.lang.UnsupportedClassVersionError: org/eclipse/jetty/server/Handler : Unsupported major.minor version 51.0”. After some Googling I found the following statement “You are using different JDK versions to compile and run the application”. No way, that is not possible. Continue reading →
Grrrr, just cloned some of my code from Github to my laptop. I initially worked on this code on my desktop. When I tried to compile it in sbt I got the following error
sbt.ResolveException: unresolved dependency: com.typesafe.play#play-json_2.11;2.3.0: not found. It had been a while since I worked on the code so I was puzzled. It turns out there are problems with the Typesafe repository. As a workaround the repository needs to be added as a resolver to the build.sbt file.
resolvers += "Typesafe Maven Repository" at "http://repo.typesafe.com/typesafe/maven-releases/"
After this it compiled nicely. Sweet. Happy coding 🙂
I wanted to add a license header to my Scala source code files. It turns out there is a neat sbt plugin called sbt-license-plugin that does just that. Getting it to work took some fiddling around, so I thought I would share it here to save someone else the time and trouble. Continue reading →
When adding to a Akka project I got the following error
java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLogger. I double checked my configuration and the Akka documentation. The documentation says the following:
Akka provides a logger for SL4FJ. This module is available in the ‘akka-slf4j.jar’. It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4J backend, we recommend Logback.
No success. Continue reading →
With SBT it is possible to download sources and javadocs of libraries. It is really straight forward, just add
withJavadoc() to the dependency. Continue reading →
Today I wanted to add one of my Github repositories to a sbt project. I was working on my Windows laptop. I setup the following Build.scala file and placed it in the project directory under the root directory of my sbt project: Continue reading →
A quick note how to create a SBT project with the latest release of Akka.
Create a build.sbt file:
name := "ScalaAkkaTest"
organization := "&lt;Your organisation name&gt;"
version := "0.1.0-SNAPSHOT"
scalaVersion := "2.11.2"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.6"
Continue reading →
I was creating a servlet using Scala and got the following error message “To compile XML syntax, the scala.xml package must be on the classpath”. It turns out that Scala-XML has been factored out into a separate library as of Scala 2.11, so it is not included in Scala projects by default. So the dependency needs to be include in the project build.sbt using the following statement:
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.2"
Note as always you should check that there isn’t a newer version available of the library. How? Google is your friend 🙂
maven org.scala-lang.modules scala-xml
This is a quick start tutorial to get going with SBT. It is meant for myself, but you are welcome to use it too 🙂
For the detailed documentation please checkout the documentation on the SBT website. Continue reading →