Posts mit dem Label SBT werden angezeigt. Alle Posts anzeigen
Posts mit dem Label SBT werden angezeigt. Alle Posts anzeigen

Donnerstag, 12. November 2015

Easy SBT build in Docker container

When you need to build your Scala project, but have no way to install SBT on your host, you can still do it if you have Docker.

There are few ready to use container images on DockerHub. We create our own.

All we need for that is to prepare a Dockerfile:

 FROM java:latest  
 MAINTAINER Nikolay Kushin nikolay@indoo.rs  
 ENV SCALA_VERSION 2.11.7  
 ENV SBT_VERSION 0.13.9  
 ENV SBT_OPTS -Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M -Duser.timezone=GMT  
 # install sbt  
 RUN wget https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb  
 RUN dpkg -i sbt-$SBT_VERSION.deb  
 # install scala  
 RUN wget https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.deb  
 RUN dpkg -i scala-$SCALA_VERSION.deb  
 # fetch base dependencies  
 RUN sbt compile  
 VOLUME /src  
 WORKDIR /src  
 CMD ["sbt"]  

Our Dockerfile is relatively easy and self-explaining.

Next step is to build an image. Save Dockerfile in some folder and execute following commande in terminal:

 docker build -t sbt-docker .  

Now when the image is ready we can create container with mounted source folder, containing our Scala project and run SBT.

 docker run -it --rm -v $(pwd):/src sbt-docker sbt docker:stage  

Thats it! Enjoy!

Freitag, 10. April 2015

Montag, 3. März 2014

API documentation for SBT project

Laika can help you easily add documentation to your SBT project. Whole process is described here and following list contains necessary steps:
  1. Add a line to your project/plugins.sbt file
    addSbtPlugin("org.planet42" % "laika-sbt" % "0.5.0")
  2. These lines to build.sbt
    import laika.sbt.LaikaSbtPlugin.{LaikaPlugin, LaikaKeys}
    import LaikaKeys._
    LaikaPlugin.defaults
  3. If you want to redefine default settings
    sourceDirectories in Laika := Seq(new java.io.File("app/docs"))
    includeAPI in Laika := true
  4. Build documentation by executing following command from SBT console
    laika:site