什么是最好的Scala构建系统? [英] What's the best Scala build system?

查看:100
本文介绍了什么是最好的Scala构建系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过有关IDE的问题 - 哪个是用于Scala开发的最佳IDE?什么是目前Scala的工具状态?,但是我已经与IDEs混合了经验。现在,我正在使用带有自动工作区刷新选项的Eclipse IDE,KDE 4的Kate作为我的文本编辑器。以下是我想解决的一些问题:

I've seen questions about IDE's here -- Which is the best IDE for Scala development? and What is the current state of tooling for Scala?, but I've had mixed experiences with IDEs. Right now, I'm using the Eclipse IDE with the automatic workspace refresh option, and KDE 4's Kate as my text editor. Here are some of the problems I'd like to solve:


  1. 使用我自己的编辑器 IDE真的适合在每个人使用他们的组件。我喜欢凯特更好,但刷新系统非常烦人(它不使用inotify,而是10秒的轮询间隔)。我不使用内置文本编辑器的原因是因为自动完成功能会导致IDE挂起10秒钟。

  2. 仅重新构建已修改的文件 Eclipse构建系统已损坏。它不知道什么时候重建课程。我发现自己差不多半个时间去投资 - >干净了。更糟糕的是,它似乎甚至在完成了我的项目,几分钟之后,它将弹出一些奇怪的错误(编辑 - 这些错误似乎是以前解决的项目>清理,但后来回来了...)。最后,如果项目包含错误,则将首选项/继续启动设置为提示似乎对Scala项目没有影响(即使有错误也始终启动)。

  3. 构建定制我可以使用夜间版本,但是我想修改和使用我自己的Scala构建,而不是IDE的插件内置的编译器。通过[例如] -Xprint:jvm 到编译器(打印出降低的代码)也是很好的。

  4. 快速编译虽然Eclipse并不总是正确的,但它似乎比较简单 - 甚至比 fsc

  1. use my own editor IDEs are really geared at everyone using their components. I like Kate better, but the refresh system is very annoying (it doesn't use inotify, rather, maybe a 10s polling interval). The reason I don't use the built-in text editor is because broken auto-complete functionalities cause the IDE to hang for maybe 10s.
  2. rebuild only modified files The Eclipse build system is broken. It doesn't know when to rebuild classes. I find myself almost half of the time going to project->clean. Worse, it seems even after it has finished building my project, a few minutes later it will pop up with some bizarre error (edit - these errors appear to be things that were previously solved with a project > clean, but then come back up...). Finally, setting "Preferences / Continue launch if project contains errors" to "prompt" seems to have no effect for Scala projects (i.e. it always launches even if there are errors).
  3. build customization I can use the "nightly" release, but I'll want to modify and use my own Scala builds, not the compiler that's built into the IDE's plugin. It would also be nice to pass [e.g.] -Xprint:jvm to the compiler (to print out lowered code).
  4. fast compiling Though Eclipse doesn't always build right, it does seem snappy -- even more so than fsc.

我看过Ant和Maven,虽然还没有使用(我也需要花时间解决#3和#4)。我想看看有没有人有其他建议,我花时间获得一个次佳的构建系统工作。感谢提前!

I looked at Ant and Maven, though haven't employed either yet (I'll also need to spend time solving #3 and #4). I wanted to see if anyone has other suggestions before I spend time getting a suboptimal build system working. Thanks in advance!

更新 - 我正在使用Maven,将项目作为编译器插件传递给它。看起来够快我不知道什么样的jar缓存Maven。 Scala 2.8.0的现有存储库可用[链接]。原型非常酷,跨平台支持似乎非常好。但是,关于编译问题,我不确定是否fsc实际上是固定的,或者我的项目是稳定的(例如,类名不改变) - 手动运行它不会打扰我。如果你想看一个例子,请随时浏览我使用的pom.xml文件[ github ]。

UPDATE - I'm now using Maven, passing a project as a compiler plugin to it. It seems fast enough; I'm not sure what kind of jar caching Maven does. A current repository for Scala 2.8.0 is available [link]. The archetypes are very cool, and cross-platform support seems very good. However, about compile issues, I'm not sure if fsc is actually fixed, or my project is stable enough (e.g. class names aren't changing) -- running it manually doesn't bother me as much. If you'd like to see an example, feel free to browse the pom.xml files I'm using [github].

更新2 - 从我看过的基准,Daniel Spiewak是正确的buildr比Maven更快(并且,如果正在进行增量更改,Maven的10秒延迟会变得烦人),所以如果可以制作一个兼容的构建文件,那么这可能值得...

UPDATE 2 - from benchmarks I've seen, Daniel Spiewak is right that buildr's faster than Maven (and, if one is doing incremental changes, Maven's 10 second latency gets annoying), so if one can craft a compatible build file, then it's probably worth it...

推荐答案

点2和4非常难以用当前的scalac进行管理。问题是Scala的编译器对于构建文件有一点愚蠢。基本上,它将构建您饲养的任何东西,无论该文件是否真的需要构建。 Scala 2.8.0将在这方面有一些巨大的改进,但直到那时... Eclipse SDT实际上有一些非常精细(和非常黑客)的代码进行更改检测和依赖关系跟踪。总的来说,它做得很好,但如你所见,有皱纹。 Eclipse SDT 2.8.0将依赖于对scalac本身的上述改进。

Points 2 and 4 are extremely difficult to manage with the current scalac. The problem is that Scala's compiler is a little dumb about building files. Basically, it will build whatever you feed it, regardless of whether or not that file really needs to be built. Scala 2.8.0 will have some tremendous improvements in this respect, but until then... Eclipse SDT actually has some very elaborate (and very hackish) code for doing change detection and dependency tracking. On the whole, it does a decent job, but as you have seen, there are wrinkles. Eclipse SDT 2.8.0 will rely on the aforementioned improvements to scalac itself.

所以,只修改修改的文件几乎是不成问题的。除SDT之外,我知道哪些甚至尝试的工具是SBT(简单构建工具)。它使用编译器插件在编译时跟踪文件,并查询编译器本身计算出的依赖关系图。在实践中,这比重新编译世界的方法大大提高了50%。再次,这是一个在2.8.0之前的缺陷的一个黑客。

So, building only modified files is pretty much out of the question. Aside from SDT, the only tool I know of which even tries this is SBT (Simple Build Tool). It uses a compiler plugin to track files as they are compiled and query the dependency graph computed by the compiler itself. In practice, this yields about a 50% improvement over the recompile-the-world approach. Once again, this is a hack to get around deficiencies in pre-2.8.0 scalac.

好消息是,即使不用担心变化,相当快的编译仍然可以实现检测。 FSC使用与Eclipse SDT用来实现快速增量编译的相同的技术(哦,这听起来像Charlie Eppes)。简单来说,这很漂亮。

The good news is that reasonably fast compilation is still achievable even without worrying about change detection. FSC uses the same technology (ooh, that sounded so "Charlie Eppes") that Eclipse SDT uses to implement fast incremental compilation. In short, it's pretty snappy.

我个人使用 Apache Buildr 。其配置比Maven或SBT的清洁度明显,启动时间比数字下降(在MRI下运行时)。它与FSC集成,并尝试自己进行一些基本的更改检测(相当原始)。它还为主要的Scala测试框架(ScalaTest,ScalaCheck和Spe​​cs)提供了自动神奇的支持,并支持与IntelliJ和Eclipse的Java源代码和IDE元生成联合编译。哦,它支持所有的Maven的功能(依赖性分辨率等),然后一些。我甚至在扩展上工作,这将允许与JavaRebel集成的交互式shell支持,并支持多个shell提供程序(Scala,JIRB,Clojure REPL等)。它还没有准备好SVN,但是一旦准备就绪(可能在1.3.5的时候)。

Personally, I use Apache Buildr. Its configuration is significantly cleaner than either Maven's or SBT's and its startup time is orders of magnitude less (when running under MRI). It integrates with FSC and attempts to do some basic change detection on its own (fairly primitive). It also has auto-magical support for the major Scala test frameworks (ScalaTest, ScalaCheck and Specs) as well as support for joint compilation with Java sources and IDE meta generation for IntelliJ and Eclipse. Oh, and it supports all of Maven's features (dependency resolution, etc) and then some. I'm even working on an extension which would allow interactive shell support integrated with JavaRebel and supporting several shell providers (Scala, JIRB, Clojure REPL, etc). It's not ready for the SVN yet, but I'll commit once it's ready (possibly in time for 1.3.5).

正如你所看到的,我很坚定地认为Buildr是最好的Scala构建工具。它的文档在Scala有一点点,但是这是因为一切都很简单,很难在没有感觉到冗长的情况下记录文档。您可以随时查看我的GitHub存储库中的一个示例。祝你好运!

As you can see, I'm very firmly of the opinion that Buildr is the best Scala build tool out there. Its documentation is a little spotty where Scala is concerned, but that's because everything is so straightforward that it's hard to document without feeling verbose. You can always check out one of my GitHub repositories for examples. Good luck!

这篇关于什么是最好的Scala构建系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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