对 Scala 应用程序进行指纹识别的最佳方法
我正在 Scala 中开发一个 Web 应用程序,我们将其部署在多个测试环境中。为了控制安装哪个软件快照,我想在生成的 .war 中包含版本指纹,以便我可以使用 REST 接口查询它。 我会设置一个 SBT 任务,从项目定义中检索 Mercurial 存储库版本、当前项目版本,并编写一个静态字符串,该字符串将从前面提到的服务中读取,但这是正确的方法吗?
获得此功能的常见模式是什么?
问候。
I'm developing a Web application in Scala that we deploy in several testing environments. In order to control which software snapshot is installed, I'd like to include a version fingerprint in the generated .war so I can query it using a REST interface.
I would go in the path of setting a SBT task that retrieves the mercurial repository version, the current project version from the project definition and compose a static string that will be read from that before mentioned service, but is this the right approach?
What are common patterns for getting this functionality?
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个想法是生成一个包含正确信息的文件,然后让一个 SBT 任务负责将该文件信息包含在生成的 war 中。
对于该文件,您可以在“如何在 PHP 页面上显示 hg 存储库的当前工作副本版本",作为更新后挂钩:
这意味着您将无法从 SBT 执行任何 Mercurial 命令:mercurial 存储库的更新将足以触发该文件的生成。
该链接答案的评论还提到了可能的 hg 命令:
The idea is to generate a file with the right information, and then have an SBT task taking care of including that file information in the generated war.
For the file, you can see the right mercurial command in "How to display current working copy version of an hg repository on a PHP page", as a post-update hook:
That means you won't have ot can any mercurial command from SBT: the update of the mercurial repo will be enough to trigger the generation of that file.
The comments of that linked answer also mention the possible hg command: