nornagon
nornagon

Reputation: 15821

Output (built files) from SBT in a separate directory

For CI, I'd like to build the project fresh every time. However, sbt compile ends up littering target folders all throughout the checkout. git clean -fxd or similar can remove those files, but is there any way to have SBT just not put them there in the first place?

Is there a way to tell SBT to put compiled files into a separate directory structure, a la CMake?

Upvotes: 1

Views: 412

Answers (2)

Matthijs Dekker
Matthijs Dekker

Reputation: 206

Even if you could instruct sbt to place the output files somewhere else, you'd still need to clean this other directory in order to get a clean compile.

If you want to build your project 'fresh', why not use sbt clean compile ?

Adding the target/ directory to .gitignore takes care of the 'littering' from a git perspective.

Upvotes: 0

Paul Draper
Paul Draper

Reputation: 83245

Easiest way:

target := file("/my/target")

However, SBT will still put files in project/target, and AFAIK there nothing you can do about that.

Though git clean -fxd isn't so bad either :) It's the best, most reliable way (no matter what your build tool does) to make a clean working tree.

Upvotes: 1

Related Questions