Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sbt, compile compiler bridge

Tags:

scala

sbt

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

like image 776
Alexander Kondaurov Avatar asked Sep 16 '18 15:09

Alexander Kondaurov


People also ask

What is sbt compiler?

sbt is a popular tool for compiling, running, and testing Scala projects of any size. Using a build tool such as sbt (or Maven/Gradle) becomes essential once you create projects with dependencies or more than one code file.

What is compiler interface?

The compiler interface is the communication link between sbt and the Scala compiler. It is used to get information from the Scala compiler, and must therefore be compiled against the Scala version in use for the configured projects.


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'
like image 134
laughedelic Avatar answered Sep 28 '22 10:09

laughedelic