如何不查看文件以了解 Play 框架中的更改 [英] How to not watch a file for changes in Play Framework

查看:25
本文介绍了如何不查看文件以了解 Play 框架中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 sbt-buildinfo 创建 的 Play Framework 2.2 项目上编译项目时BuildInfo.scala文件,如何配置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 框架中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆