Skip to content

Instantly share code, notes, and snippets.

@daimatz
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daimatz/a802f22f118bb44b4c06 to your computer and use it in GitHub Desktop.
Save daimatz/a802f22f118bb44b4c06 to your computer and use it in GitHub Desktop.
sbt assembly for Finatra application
import sbt._
import sbt.Keys._
import sbtassembly.Plugin.{MergeStrategy, assemblySettings, defaultMergeStrategy}
import sbtassembly.Plugin.AssemblyKeys.{assembly, mergeStrategy}
import sbtassembly.AssemblyUtils
object AppBuild extends Build {
lazy val app = Project(
id = "app",
base = file("app"),
settings = Project.defaultSettings ++ assemblySettings
).settings(
libraryDependencies ++= Seq(
"com.twitter" %% "finatra" % "1.5.3"
),
mergeStrategy in assembly <<= (mergeStrategy in assembly) {
val discardJar = new MergeStrategy {
val name = "discard_jar"
def apply(tempDir: File, path: String, files: Seq[File]): Either[String, Seq[(File, String)]] = {
Right(
for {
// collects not jar-origined
f <- files if !AssemblyUtils.sourceOfFileForMerge(tempDir, f)._4
} yield {
f -> path
}
)
}
}
(old) => { x: String =>
val sep = System.getProperty("file.separator")
if (x.endsWith(".mustache") || x.startsWith("public" + sep)) {
// discards files from other jars. only accepts files from app/*.
discardJar
} else {
old(x)
}
}
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment