Packaging Compiled Scala Files Into Jars with SBT

I am working with Play Framework, Scala and SBT. I needed to divide my project into modules because it was getting too big. Since I am not familiar with SBT, I created a dummy project to play around. My dummyproject has some controllers in itself, a core module with some utilities and a models module that uses some utilities from core module.

My primary objective here is to avoid compiling modules unless it is absolutely necessary (e.g. it's code is changed.).

I can make modules depend on each other using dependsOn but as far as I understand, they depend on the code of other module.

What I'd like to do is to somehow package compiled files of each module into jar files, and make dependencies use jar files instead of code itself. How can I accomplish this?

Upvotes: 0

Views: 121

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170839

My primary objective here is to avoid compiling modules unless it is absolutely necessary (e.g. it's code is changed.).

That's what SBT does. If the code didn't change, the modules won't be recompiled. Even if the code changed, it may be able to detect this change can't influence dependent modules (e.g. if you only changed private members) and won't recompile them. If you depend on jar files instead, it'll hurt incremental compilation and force SBT to recompile your files more.

If you do want to depend on JARs, one way is to split your project into several independent projects instead of modules and add the dependencies in the same way you'd add any other library.

Upvotes: 2

Related Questions