Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to compile single file in sbt

Tags:

scala

sbt

I'm doing some refactoring that made compiler temporally give errors in several files. I'd like to work with them one by one (starting with common dependencies) and need some tool to check if modification is correct.

sbt compile is inconvenient because it gives too many errors and spends much time for compiling things that have no good.

I'm searching for a way to compile single file with sbt or a method for extracting sbt side libraries definition to pass them to a normal scalac compiler

There was a similar topic: How to compile just some files with sbt? that turned out to be source code error discussion rather that sbt functionality disclosure.

like image 412
ayvango Avatar asked Jan 04 '13 16:01

ayvango


2 Answers

You could add the following line to build.sbt:

sources in Compile <<= (sources in Compile).map(_ filter(_.name == "Particular.scala"))

Then fix Particular.scala, then edit build.sbt and put the name of the next source file. If you keep the sbt console open, reload will re-read the .sbt file after you modify it.

like image 124
0__ Avatar answered Sep 21 '22 03:09

0__


I just wanted to mention here that I came across sbt-compile-quick-plugin (https://github.com/etsy/sbt-compile-quick-plugin). It does what it says on the tin, just add addSbtPlugin("com.etsy" % "sbt-compile-quick-plugin" % "1.3.0") to your project/plugins.sbt, then you can just start up sbt and run compileQuick /path/to/your/file

like image 21
Mani Avatar answered Sep 21 '22 03:09

Mani