热门标签 | 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和增量编译。


推荐阅读
  • Java 11相对于Java 8,OptaPlanner性能提升有多大?
    本文通过基准测试比较了Java 11和Java 8对OptaPlanner的性能提升。测试结果表明,在相同的硬件环境下,Java 11相对于Java 8在垃圾回收方面表现更好,从而提升了OptaPlanner的性能。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • vue使用
    关键词: ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 自动轮播,反转播放的ViewPagerAdapter的使用方法和效果展示
    本文介绍了如何使用自动轮播、反转播放的ViewPagerAdapter,并展示了其效果。该ViewPagerAdapter支持无限循环、触摸暂停、切换缩放等功能。同时提供了使用GIF.gif的示例和github地址。通过LoopFragmentPagerAdapter类的getActualCount、getActualItem和getActualPagerTitle方法可以实现自定义的循环效果和标题展示。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • 欢乐的票圈重构之旅——RecyclerView的头尾布局增加
    项目重构的Git地址:https:github.comrazerdpFriendCircletreemain-dev项目同步更新的文集:http:www.jianshu.comno ... [详细]
  • Android系统源码分析Zygote和SystemServer启动过程详解
    本文详细解析了Android系统源码中Zygote和SystemServer的启动过程。首先介绍了系统framework层启动的内容,帮助理解四大组件的启动和管理过程。接着介绍了AMS、PMS等系统服务的作用和调用方式。然后详细分析了Zygote的启动过程,解释了Zygote在Android启动过程中的决定作用。最后通过时序图展示了整个过程。 ... [详细]
  • 重入锁(ReentrantLock)学习及实现原理
    本文介绍了重入锁(ReentrantLock)的学习及实现原理。在学习synchronized的基础上,重入锁提供了更多的灵活性和功能。文章详细介绍了重入锁的特性、使用方法和实现原理,并提供了类图和测试代码供读者参考。重入锁支持重入和公平与非公平两种实现方式,通过对比和分析,读者可以更好地理解和应用重入锁。 ... [详细]
  • 本文整理了Java面试中常见的问题及相关概念的解析,包括HashMap中为什么重写equals还要重写hashcode、map的分类和常见情况、final关键字的用法、Synchronized和lock的区别、volatile的介绍、Syncronized锁的作用、构造函数和构造函数重载的概念、方法覆盖和方法重载的区别、反射获取和设置对象私有字段的值的方法、通过反射创建对象的方式以及内部类的详解。 ... [详细]
  • Netty源代码分析服务器端启动ServerBootstrap初始化
    本文主要分析了Netty源代码中服务器端启动的过程,包括ServerBootstrap的初始化和相关参数的设置。通过分析NioEventLoopGroup、NioServerSocketChannel、ChannelOption.SO_BACKLOG等关键组件和选项的作用,深入理解Netty服务器端的启动过程。同时,还介绍了LoggingHandler的作用和使用方法,帮助读者更好地理解Netty源代码。 ... [详细]
  • 开发笔记:Python之路第一篇:初识Python
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了Python之路第一篇:初识Python相关的知识,希望对你有一定的参考价值。Python简介& ... [详细]
  • 初识java关于JDK、JRE、JVM 了解一下 ... [详细]
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社区 版权所有