问题
I need to include entire static
directory from external location in my SBT-generated JAR file (with optional folder renaming).
Adding it's path to unmanagedResourceDirectories
adds its content only, not the entire directory which results in static
content in the JAR root. I was playing with mappings of various sorts but with no luck.
Does anyone had similar use-case and could point me to the right direction on how to do that?
I can't modify the process that generates the static
dir and can't use it's parent as it has other files/dirs I don't want inside.
回答1:
Ok, I sorted it out with a little hint I got on sbt's gitter channel. So mappings
is what I needed:
mappings in (Compile, packageBin) := {
val statics = contentOf(baseDirectory.value / "static").map {
case (file, dest) => file -> s"webapp/$dest"
}
(mappings in (Compile, packageBin)).value ++ statics
}
This will take all the content from static
directory and place it in the webapp
directory of the resulting JAR file
来源:https://stackoverflow.com/questions/51614886/sbt-include-entire-external-directory-with-the-dir-itself-in-jar-built