热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

什么是最好的Scala构建系统?-What'sthebestScalabuildsystem?

IveseenquestionsaboutIDEshere--WhichisthebestIDEforScaladevelopment?andWhatisthe

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:

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

  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. 使用我自己的编辑器IDE真的适合每个人使用他们的组件。我更喜欢Kate,但刷新系统非常烦人(它不使用inotify,而是使用10s轮询间隔)。我不使用内置文本编辑器的原因是因为破坏的自动完成功能导致IDE挂起大约10秒。

  3. 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).
  4. 仅重建已修改的文件Eclipse构建系统已损坏。它不知道何时重建类。我发现自己几乎有一半的时间去投射 - >干净。更糟糕的是,似乎即使它完成了我的项目构建,几分钟后它会弹出一些奇怪的错误(编辑 - 这些错误似乎是先前通过项目解决的问题>干净,但随后又回来了。 ..)。最后,将“首选项/继续启动,如果项目包含错误”设置为“提示”似乎对Scala项目没有影响(即,即使存在错误也始终启动)。

  5. 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).
  6. 构建定制我可以使用“nightly”版本,但我想修改和使用我自己的Scala版本,而不是IDE插件中内置的编译器。将[例如] -Xprint:jvm传递给编译器(打印出降低的代码)也是很好的。

  7. fast compiling Though Eclipse doesn't always build right, it does seem snappy -- even more so than fsc.
  8. 快速编译虽然Eclipse并不总是正确构建,但它确实看起来很快 - 甚至比fsc更强大。

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!

我看了Ant和Maven,虽然还没有使用过(我还需要花时间解决#3和#4)。在我花时间让一个次优的构建系统工作之前,我想看看是否有人有其他建议。提前致谢!

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].

更新 - 我现在正在使用Maven,将项目作为编译器插件传递给它。看起来足够快;我不确定Maven做什么样的jar缓存。可以使用Scala 2.8.0的当前存储库[link]。原型非常酷,跨平台支持似乎非常好。但是,关于编译问题,我不确定fsc是否实际修复,或者我的项目是否足够稳定(例如类名不会改变) - 手动运行它并不会让我感到烦恼。如果您想查看示例,请随意浏览我正在使用的[github]的pom.xml文件。

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 - 从我见过的基准测试中,Daniel Spiewak是正确的,构建器比Maven快(并且,如果一个人正在进行增量更改,Maven的10秒延迟变得烦人),所以如果可以制作兼容的构建文件,那么它可能是值得...

8 个解决方案

#1


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.

使用当前的scalac非常难以管理第2点和第4点。问题是Scala的编译器对于构建文件有点愚蠢。基本上,它会构建您提供的任何内容,无论该文件是否真的需要构建。 Scala 2.8.0在这方面会有一些巨大的改进,但在那之前...... Eclipse SDT实际上有一些非常精细(和非常hackish)的代码用于进行变更检测和依赖性跟踪。总的来说,它做得不错,但正如你所看到的,有皱纹。 Eclipse SDT 2.8.0将依赖于对scalac本身的上述改进。

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.

因此,仅构建修改过的文件几乎是不可能的。除了SDT之外,我所知道的唯一一个甚至尝试过它的工具是SBT(简单构建工具)。它使用编译器插件在编译时跟踪文件,并查询编译器本身计算的依赖图。在实践中,这比重新编译世界的方法产生了大约50%的改进。再次,这是一个克服2.8.0之前的scalac缺陷的黑客。

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.

好消息是即使不担心变化检测,合理快速的编译仍然是可以实现的。 FSC使用Eclipse SDT用于实现快速增量编译的相同技术(噢,听起来像是“Charlie Eppes”)。简而言之,它非常活泼。

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).

就个人而言,我使用的是Apache Buildr。它的配置比Maven或SBT更清洁,其启动时间少了几个数量级(在MRI下运行时)。它与FSC集成,并尝试自己进行一些基本的变化检测(相当原始)。它还对主要的Scala测试框架(ScalaTest,ScalaCheck和Spe​​cs)提供自动魔术支持,并支持使用Java源和IntelliJ和Eclipse的IDE元代联合编译。哦,它支持所有Maven的功能(依赖解析等),然后一些。我甚至正在开发一个扩展,它允许与JavaRebel集成的交互式shell支持并支持几个shell提供程序(Scala,JIRB,Clojure REPL等)。它还没有为SVN做好准备,但是一旦它准备好我就会做好准备(可能及时为1.3.5)。

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!

正如您所看到的,我非常坚定地认为Buildr是最好的Scala构建工具。它的文档在Scala方面有点不合理,但那是因为一切都很简单,所以很难在不感到啰嗦的情况下进行记录。您可以随时查看我的一个GitHub存储库以获取示例。祝好运!

#2


Have you looked at Intellij IDEA and its Scala integration ? Intellij has a loyal (fanatical?) following amongst Java developers, so you may find this is appropriate for your needs.

您是否看过Intellij IDEA及其Scala集成? Intellij在Java开发人员中有忠诚(狂热?)的追随者,因此您可能会发现这适合您的需求。

#3


Am also quite frustrated with the scala plugin on Eclipse and I can add a few more problems to the list:

我也对Eclipse上的scala插件感到非常沮丧,我可以在列表中添加更多问题:

  • auto-complete only works some of the time
  • 自动完成仅在某些时候有效

  • the debugger doesn't work properly (especially when trying to debug scala xml)
  • 调试器无法正常工作(特别是在尝试调试scala xml时)

  • the debugger forgets breakpoints
  • 调试器会忘记断点

  • 'go to definition' doesn't work more often than not.
  • “去定义”不会经常发挥作用。

I'm glad to hear that Buildr sounds like a better alternative (on the build front anyhow), I'll give that a try - thanks!

我很高兴听到Buildr听起来像一个更好的选择(无论如何在构建方面),我会试一试 - 谢谢!

#4


For the reasons of completeness, I have to say that there is also Pants -- the build tool that in use in Twitter (one of the early scala adopters)

出于完整性的原因,我不得不说还有Pants - 在Twitter中使用的构建工具(早期的scala采用者之一)

The main difference it that it is intended not only for scala (and written in python, by the way) and is modeled after google build system.

它的主要区别在于它不仅适用于scala(并且使用python编写,顺便说一句),并且是在google构建系统之后建模的。

It's not so bloated as sbt, so for the freshmans it's much simplier, but I've never heard about Pants usage outside of twitter and foursquare.

它不像sbt那么臃肿,所以对于新手来说它更简单,但我从来没有听说过Twitter和foursquare以外的Pants用法。

If you scared of SBT, maybe another no-so-popular build tool, ABT, could be an alternative for you?

如果你害怕SBT,也许另一种不那么受欢迎的构建工具ABT可能是你的另一种选择吗?

#5


I went down the same road, and here is where I am at: - After some initial investigation, I dropped Kate. I love to use it for most things, but when it came to things like defining tab completions, I found it sorely lacking. I would recommend that you look into gedit instead, which is much more robust for Scala development - With gedit as my editor, I use SBT and have found it to be a great build tool. I can put it into a 'test' mode where when any code changes it recompiles the relevant files and runs my test suite. This has been an extremely effective way to work.

我走了同一条路,这就是我所在的地方: - 经过一些初步调查后,我放弃了凯特。我喜欢在大多数情况下使用它,但是当涉及定义标签完成之类的东西时,我发现它非常缺乏。我建议你研究gedit,这对于Scala开发来说更加强大 - 使用gedit作为我的编辑器,我使用SBT并发现它是一个很棒的构建工具。我可以将它置于'测试'模式,当任何代码更改时,它重新编译相关文件并运行我的测试套件。这是一种非常有效的工作方式。

I have not taken a look at Buildr yet. I would like to say that I will, but honestly with SBT at my disposal I don't really have a compelling need to look at another build tool.

我还没看过Buildr。我想说我会,但老实说,SBT可供我使用,我真的没有必要去看另一个构建工具。

#6


If you use Emacs, I think Ensime is a pretty good IDE. I think at the time writing, Ensime is the only IDE that will give you fast and accurate autocompletion on both Scala and Java objects, including implicit conversions.

如果您使用Emacs,我认为Ensime是一个非常好的IDE。我认为在撰写本文时,Ensime是唯一能够为您提供Scala和Java对象快速准确自动完成功能的IDE,包括隐式转换。

There's code browsing support using Speedbar, code templates using the excellent Yasnippet, and code completion menu using Autocomplete. These are all very modern, actively maintained Emacs packages. There's also out of the box incremental building support for Maven and SBT.

有使用Speedbar的代码浏览支持,使用优秀Yasnippet的代码模板,以及使用自动完成功能的代码完成菜单。这些都是非常现代,积极维护的Emacs包。对于Maven和SBT,还有开箱即用的增量构建支持。

There's a lot more in there such as interactive debugging, refactoring, and the Scala interpreter in an inferior process. All the things you want in a modern IDE for Scala is already there in Ensime. Highly recommended for Emacsens.

还有更多内容,例如交互式调试,重构和Scala解释器,这是一个劣质的过程。在Scala的现代IDE中你想要的所有东西都已经存在于Ensime中。强烈推荐给Emacsens。

#7


If you want to use Eclipse, but build the project using sbt, and still be able to debug, take a look at this post here:

如果你想使用Eclipse,但是使用sbt构建项目,并且仍然可以调试,请看这里的帖子:

zikaprog.wordpress.com/2010/04/19/scala-eclipse-sbt-and-debugging/

It also can be applied to builders other than sbt.

它也可以应用于sbt以外的构建者。

#8


The latest version of the Maven Scala plugin supports Zinc/Nailgun for faster start times and faster incremental builds. See Zinc and Incremental Compilation.

最新版本的Maven Scala插件支持Zinc / Nailgun,可实现更快的启动时间和更快的增量构建。请参阅Zinc和增量编译。


推荐阅读
  • 深入解析Spring启动过程
    本文详细介绍了Spring框架的启动流程,帮助开发者理解其内部机制。通过具体示例和代码片段,解释了Bean定义、工厂类、读取器以及条件评估等关键概念,使读者能够更全面地掌握Spring的初始化过程。 ... [详细]
  • 本文介绍如何使用 Android 的 Canvas 和 View 组件创建一个简单的绘图板应用程序,支持触摸绘画和保存图片功能。 ... [详细]
  • 本文探讨了使用C#在SQL Server和Access数据库中批量插入多条数据的性能差异。通过具体代码示例,详细分析了两种数据库的执行效率,并提供了优化建议。 ... [详细]
  • 本文详细介绍了优化DB2数据库性能的多种方法,涵盖统计信息更新、缓冲池调整、日志缓冲区配置、应用程序堆大小设置、排序堆参数调整、代理程序管理、锁机制优化、活动应用程序限制、页清除程序配置、I/O服务器数量设定以及编入组提交数调整等方面。通过这些技术手段,可以显著提升数据库的运行效率和响应速度。 ... [详细]
  • 本文探讨了如何通过预处理器开关选择不同的类实现,并解决在特定情况下遇到的链接器错误。 ... [详细]
  • HTML基础入门指南
    本文将深入浅出地介绍HTML的基础知识,包括其定义、开发工具、制定机构、特性、基本标签及更多实用内容。 ... [详细]
  • 在编译BSP包过程中,遇到了一个与 'gets' 函数相关的编译错误。该问题通常发生在较新的编译环境中,由于 'gets' 函数已被弃用并视为安全漏洞。本文将详细介绍如何通过修改源代码和配置文件来解决这一问题。 ... [详细]
  • 本文深入探讨了 Delphi 中类对象成员的核心概念,包括 System 单元的基础知识、TObject 类的定义及其方法、TClass 的作用以及对象的消息处理机制。文章不仅解释了这些概念的基本原理,还提供了丰富的补充和专业解答,帮助读者全面理解 Delphi 的面向对象编程。 ... [详细]
  • cJinja:C++编写的轻量级HTML模板引擎
    本文介绍了cJinja,这是一个用C++编写的轻量级HTML模板解析库。它利用ejson来处理模板中的数据替换(即上下文),其语法与Django Jinja非常相似,功能强大且易于学习。 ... [详细]
  • 20100423:Fixes:更新批处理,以兼容WIN7。第一次系统地玩QT,于是诞生了此预备式:【QT版本4.6.0&#x ... [详细]
  • 本文详细探讨了HTML表单中GET和POST请求的区别,包括它们的工作原理、数据传输方式、安全性及适用场景。同时,通过实例展示了如何在Servlet中处理这两种请求。 ... [详细]
  • Struts与Spring框架的集成指南
    本文详细介绍了如何将Struts和Spring两个流行的Java Web开发框架进行整合,涵盖从环境配置到代码实现的具体步骤。 ... [详细]
  • 本文详细介绍了 Java 中的 org.apache.hadoop.registry.client.impl.zk.ZKPathDumper 类,提供了丰富的代码示例和使用指南。通过这些示例,读者可以更好地理解如何在实际项目中利用 ZKPathDumper 类进行注册表树的转储操作。 ... [详细]
  • 在创建新的Android项目时,您可能会遇到aapt错误,提示无法打开libstdc++.so.6共享对象文件。本文将探讨该问题的原因及解决方案。 ... [详细]
  • 搭建Jenkins、Ant与TestNG集成环境
    本文详细介绍了如何在Ubuntu 16.04系统上配置Jenkins、Ant和TestNG的集成开发环境,涵盖从安装到配置的具体步骤,并提供了创建Windows Slave节点及项目构建的指南。 ... [详细]
author-avatar
mobiledu2502857823
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有