【发布时间】:2014-09-30 01:09:17
【问题描述】:
我们正在使用sbt 和xsbt-web-plugin 来开发我们的liftweb 应用程序。在我们的项目构建中,我们有几个子项目,我们使用 dependencies 或 Project 在所有子项目之间共享一些东西。
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(...)
}
// ...
}
为了简化开发,我们使用'project standalone' '~;container:start; container:reload /' 命令自动重新编译更改的文件。
我们决定也提供来自共享 core 项目的一些常见资产。这适用于电梯。但是当我们将文件添加到core/src/main/resources/toserve 文件夹时,我们面临的是对任何 javascript 或 css 文件的任何更改都会导致应用程序重新启动码头。这很烦人,因为这种重新加载会占用大量资源。
所以我开始研究如何防止这种情况,甚至发现有人提到watchSources sbt 扫描更改文件的任务。
但是将此代码添加为watchSources 修改(println 打印所有文件的事件)不会阻止每次更改位于coreresources 文件夹中的资产时重新加载 webapp。
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")
} }
)
我还尝试将excludeFilter 添加到unmanagedSorces、unmanagedResorces,但没有成功。
我不是 sbt 专家,对设置的这种修改对我来说更像是一种魔法(而不是普通的代码)。文档似乎也发现了这种调整=( 谁能帮我防止 sbt 在每次资产文件更改时重新加载 webapp?
非常感谢!
【问题讨论】:
标签: sbt lift xsbt-web-plugin