Scala+IDEA:sbt 和 fsc 的优缺点
我目前正在使用 IDEA 的构建机制和 fsc 来使用 Scala 进行开发。它仍然有点慢,并且必须(重新)启动编译服务器很痛苦。这里很多人建议将 SBT 与 IDEA 一起作为构建工具。
您认为每种方法的优缺点是什么?
I'm currently using IDEA's build mechanism with fsc for developing with Scala. It's still a bit slow and having to (re) start the compilation server is a pain. Many people here are suggesting SBT as a build tool together with IDEA.
What do you consider the pros and cons of each approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我两种都尝试过,最后我更喜欢直接使用 sbt 进行编译。
缺点?我真的很怀念能够点击编译错误并直接修复代码,但是......在 sbt 中编译速度要快得多。
Idea Scala 插件的夜间构建可能在质量/性能方面有所不同,但最近它变得越来越好。 Scala 插件现在可以标记一些错误,以前我必须运行编译才能捕获这些错误。 (例如,我正在运行 nightly build 0.4.693,新方法检查已经非常有用。)
我对在命令行上使用 sbt 的建议:启动 sbt 并让它以交互方式运行,尽可能长时间地运行充分利用所有内容都已加载并进行 JIT 编辑的优势。
sbt left running 最终会崩溃,但是通过在 sbt 包装器中为其提供更多内存,您可以很少发生这种情况。
这是适合我的 sbt 启动包装器。
我对 sbt 0.7 的最大问题是它经常返回并重新编译大量文件,这些文件似乎与我实际更改的代码无关。 (即便如此,仍然比 Idea 和 fsc 更快!)
好消息:sbt 0.9 有一些很棒的增量编译改进。不幸的是,从 0.7 到 0.9 的迁移仍处于早期阶段。 Mark Harrah 在 NEScala 上的演讲可在线访问 http://www.nescala.org/2011/(如果您愿意)有兴趣。
有用的插件
I tried both and in the end I prefer straight sbt for compiling.
Cons? I really miss being able to click through compile errors and fix the code directly, but... compiling in sbt is just much faster.
The nightly builds of the Idea Scala plugin can vary in quality/performance, but it's been getting better and better lately. The Scala plugin can now flag a number of errors that before I would have had to run compile to catch. (For example, I'm running nightly build 0.4.693 and the new method inspections have already been dead helpful.)
My advice for life with sbt on the command line: start sbt up and leave it running interactively as long as possible to take advantage of everything being loaded and JIT-ed.
sbt left running will fall over eventually but by giving it more memory in your sbt wrapper you can make that happen only rarely.
Here's the sbt launch wrapper that works for me.
My biggest issue with sbt 0.7 is that it frequently goes back and recompiles great swathes of files that seem only tangential to the code I was actually changing. (Even so, still faster than Idea and fsc!)
Good news: sbt 0.9 has some great incremental compile improvements. Unfortunately, the migration path from 0.7 to 0.9 is still in its early days. Mark Harrah's presentation at NEScala is online at http://www.nescala.org/2011/ if you're interested.
Useful plugins