在 sbt 和 Scala play 框架之间共享源代码/库
我正在 Scala 中开发两个相关的应用程序。一种是使用 SBT 构建的服务器端处理引擎,并无头运行(在 cron 作业上)进行一些数字运算。另一个是用 Scala 编写并在 play 框架上运行的网站。
我希望能够在两者之间共享代码,但由于它们每个人(SBT 和 Play)对目录结构以及如何构建东西都有自己的想法,所以我很不清楚应该如何做到这一点。我讨厌复制和粘贴 .scala 文件 - 但我也不热衷于使用符号链接并让它们都从相同的文件构建。
如果可能的话,我会接受让 Play 脚本运行 SBT 以根据需要构建库。如果这是唯一的方法,那么我也可以使用 SBT 为 Play 构建 jar,然后将它们复制到位。但我经常同时开发两者(它们是一个更大的应用程序的一部分),如果它们一起更新,一切都会更加顺利。这是否可能,或者我是否缺少另一种更简单的技术?
谢谢,亚历克斯
I have two related apps I am developing in Scala. One is a server-side processing engine built using SBT and running headlessly doing some number crunching (on a cron job). The other is a web site written in Scala and running on the play framework.
I have code that I would like to be able to share between the two, but as each of them (SBT and Play) has their own ideas about directory structure and how to build things it's pretty unclear to me how I should do this. I'd hate to copy and paste the .scala files - but I'm also not keen on using sym links and having them both build from the same files.
If it were possible, I would accept getting the Play scripts to run SBT to build libraries as required. If it were the only way then I would also be OK with using SBT to build jars for Play and then copying them into place. But I'm often developing both simultaneously (they are parts of a bigger app) and it would all work much more smoothly if they updated together. Is this even possible, or if there's another simpler technique I'm missing?
Thanks, Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
唯一简单的方法是使用 SBT 构建 JAR 并让 Play 使用它们。
关于如何复制,您有 2 个选择:
playsync --deps
并调整版本,所以我不确定它在开发过程中是否有意义(一旦 JAR 发布,它就更有意义)虽然完整)The only easy way is to build JARs with SBT and make Play use them.
On how to copy, you have 2 options:
play sync --deps
often and to tweak the versions, so I'm not sure if it makes too much sense during dev (it makes more sense once the JARs are complete though)