Sbt, compile compiler bridge

Viewed 5436

I want to build a docker image with sbt.

Here is what i have:

FROM kondaurov/jdk-alpine:jdk8slim

ENV SBT_VERSION=1.2.1

RUN \
 echo "$SBT_VERSION" && \
 curl -fsL https://github.com/sbt/sbt/releases/download/v${SBT_VERSION}/sbt-${SBT_VERSION}.tgz | tar xfz - -C /usr/local && \
 ln -s /usr/local/sbt/bin/* /usr/local/bin/ && \
 sbt sbtVersion

ENTRYPOINT sbt

When i use this image with my scala project i get this:

[warn] Run 'evicted' to see detailed eviction warnings

[info] Compiling 4 Scala sources to /sbt_project/project/target/scala-2.12/sbt-1.0/classes ...

[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.6. Compiling...

[info]   Compilation completed in 53.746s.

As you see sbt always compiles compiler bridge for scala and it takes some time.. Is it possible to compile bridge in my image? I guess sbt sbtVersion isn't enough

1 Answers

It's triggered on the first compilation, so you can change the sbt sbtVersion line to sbt compile. Most likely you will need to add a simple Scala source file in the working directory to trigger the compilation (and then clean up the produced output).

You can also set a specific Scala version without creating a build.sbt:

sbt 'set scalaVersion := "2.11.8"' compile

or even several:

sbt 'set crossScalaVersions := Seq("2.11.8", "2.12.6")' '+compile'
Related