问题描述
在使用 sbt-buildinfo 创建 的 Play Framework 2.2 项目上BuildInfo.scala
文件编译项目时,如何配置 build.sbt
以使 Play Framework 不会监视 BuildInfo.scala
文件的更改,并且如果该文件发生更改不会重新启动服务器?
例如,如果会话开始于:
$ sbt ~run
并且服务器以开发模式启动,然后在另一个终端窗口中启动另一个 sbt
会话(运行另一个子项目,或者只是运行其他 sbt
任务),第二个 sbt
会话将更新 BuildInfo.scala
文件,第一个 sbt
会话将检测到这一点并重新加载 Play 项目.>
所以问题是如何从监控中排除BuildInfo.scala
(但仍然编译它并将其包含在分发包中).
显然 watchSources
配置选项可以提供帮助,但在阅读文档后我无法弄清楚如何使用它来排除文件.
要从被监视的文件中移除特定文件,您可以在 build.sbt
中执行:
watchSources := watchSources.value.filter { _.getName != "BuildInfo.scala" }
我试图重现基本设置,但对我来说 BuildInfo.scala 文件没有被监视.您可以通过发出 show watchSources
来查看观看的源列表.
On a Play Framework 2.2 project that is using sbt-buildinfo to create a BuildInfo.scala
file when the project is compiled, how can build.sbt
be configured so that Play Framework won't watch the BuildInfo.scala
file for changes, and won't restart the server if that file changes?
For instance, if a session is started with:
$ sbt ~run
and the server starts in development mode, and then in another terminal window another sbt
session is started (to run another subproject, or just to run other sbt
tasks), this second sbt
session will update the BuildInfo.scala
file, and the first sbt
session will detect this and reload the Play project.
So the question is how to exclude BuildInfo.scala
from monitoring (but still compile it and include it in the distribution package).
Apparently the watchSources
configuration option could help, but after reading the documentation I couldn't figure out how to use it to exclude a file.
To remove a particular file from being watched you can do in build.sbt
:
watchSources := watchSources.value.filter { _.getName != "BuildInfo.scala" }
I tried to reproduce basic setup, and for me the BuildInfo.scala file is not watched. You can see the list of watched sources by issuing show watchSources
.
这篇关于如何不观看文件以了解 Play Framework 中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!