I'm using embedded jetty and need to include webapp in my jar when
package.
I've figured out I need to hook into copyResources task but have no
clearness with how it works.
What I want is to copy webapp to the classes dir root.
The same result can be achieved by copying src/main/webapp to src/main/
resources/webapp,
but I want to change build setting rather than modifying directory
structure.
Thanks.
mappings in (Compile, packageBin) ~= { _ ++ (file("src/main/webapp") *
"*" x Path.flatRebase("webapp")) }
That will include everything normally in the package (from the "_"
above) plus will copy everything in src/main/webapp to /webapp within
your package.
On Dec 2, 2:05 am, Alexey Lunacharsky <alexey.lunachar...@gmail.com>
wrote:
mappings in (Compile, packageBin) <<= (mappings in (Compile,
packageBin), baseDirectory) map { (mappings, base) =>
val webappBase = (base / "src" / "main" / "webapp")
mappings ++ (webappBase ** "*" x rebase(webappBase, "webapp"))
}
But this only adds webapp to binaries .jar, and this is only a half of
the solution.
I'd wanted webapp also present in ..../classes dir of the target sbt
folder, which is supposed to be the classpath of the run-main task.
resourceGenerators in Compile <+= (resourceManaged,
baseDirectory) map { (managedBase, base) =>
val webappBase = base / "src" / "main" / "webapp"
for {
(from, to) <- webappBase ** "*" x rebase(webappBase,
managedBase / "main" / "webapp")
} yield {
Sync.copy(from, to)
to
}
}
What I've done wrong before is have missed the "main" folder in the
path and due to that was getting flat file mapping in copyResources
task, which
was causing duplicate mapping (I had two index.html in different
webapp folders).
I've looked to "last copy-resources" output and to the copyResources
source code, that helped.
Anyway, thanks!
On 4 дек, 13:40, Alexey Lunacharsky <alexey.lunachar...@gmail.com>
wrote: