Richard Searle

home

Absolute file reference for SBT assembly

01 Nov 2015

The sbt documentation always indicates that file path must be absolute, but all examples are relative to project base. That leaves it a little unclear as to how files outside of the project directory might be referenced.

I created a polyglot project with an Akka backend and React.js frontend. These were placed in separate directories since the linkage is small and at arms-length. There was no need to determine how to integrate webpack into sbt.

Deployment into the test environment required a fat-jar, generated by sbt-assembly. The fat-jar needed to include the js and html files from the webpack build process.

The solution turns out to to be simple, even obvious.

unmanagedResourceDirectories in Compile += file("../../react/build")

or

unmanagedResourceDirectories in Compile += file("/home/rsearle/work/react/build")

The assembly plugin unfortunately does not (AFAIK) allow the specification of resources that are only included during the actual packaging process.