问题描述
在使用 sbt-buildinfo 创建一个BuildInfo.scala
的Play Framework 2.2项目中编译项目时的文件,如何配置build.sbt
以便Play Framework不会监视BuildInfo.scala
文件的更改,并且如果该文件更改也不会重新启动服务器?
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
,服务器以开发模式启动,然后在另一个终端窗口中启动另一个sbt
会话(以运行另一个子项目,或仅运行其他sbt
任务),第二个sbt
会话将更新BuildInfo.scala
文件,并且第一个sbt
会话将检测到该文件并重新加载Play项目.
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.
所以问题是如何将BuildInfo.scala
从监视中排除(但仍将其编译并包含在分发包中).
So the question is how to exclude BuildInfo.scala
from monitoring (but still compile it and include it in the distribution package).
显然,watchSources
配置选项可以提供帮助,但是在阅读了文档之后,我不知道如何使用它来排除文件.
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.
推荐答案
要删除某个特定文件,可以在build.sbt
中进行操作:
To remove a particular file from being watched you can do in build.sbt
:
watchSources := watchSources.value.filter { _.getName != "BuildInfo.scala" }
我试图重现基本设置,但对我而言,BuildInfo.scala文件未被监视.您可以通过发出show watchSources
来查看受监视来源的列表.
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框架中不监视文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!