We are using sbt
with xsbt-web-plugin
to develop our liftweb app. In our project build we have several subprojects and we use dependencies
of a Project
to share some stuff between all the subprojects.
object ProjectBuild extends Build {
//...
lazy val standalone = Project(
id = "standalone",
base = file("standalone"),
settings = Seq(...),
dependencies = Seq(core) // please notice this
)
lazy val core = Project(
id = "core",
base = file("core"),
settings = Seq(...)
}
// ...
}
To ease the development we use 'project standalone' '~;container:start; container:reload /'
command automatically recompile changed files.
We decided to serve some common assets from shared core
project as well. This works fine with lift. But what we faced when added our files to core/src/main/resources/toserve
folder, is that any change to any javascript or css file causes application to restart jetty. This is annoying since such reload takes lots of resources.
So I started investigating on how to prevent this, even found someone mentioning watchSources
sbt task that scans for changed files.
But adding this code as a watchSources
modification (event that println
prints all the files) does not prevent from reloading webapp each time I change assets located in core
resources
folder.
lazy val core = Project(
id = "core",
base = file("core"),
settings = Seq(
// ...
// here I added some tuning of watchSources
watchSources ~= { (ws: Seq[File]) => ws filterNot { path =>
println(path.getAbsolutePath)
path.getAbsolutePath.endsWith(".js")
} }
)
I also tried adding excludeFilter
to unmanagedSorces
, unmanagedResorces
but with no luck.
I'm not an sbt expert and such modification of settings looks more like a magic for me (rather then a usual code). Also such tuning seem to be uncovered by documentation =( Can anyone please help me to prevent sbt from reloading webapp on each asset file change?
Thanks a lot!