Last active
August 29, 2015 14:05
-
-
Save daimatz/a802f22f118bb44b4c06 to your computer and use it in GitHub Desktop.
sbt assembly for Finatra application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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