scala 是否可以使用gradle开发scala项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23409375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 06:14:38  来源:igfitidea点击:

Is it possible to use gradle to develop scala projects?

scalagradlesbt

提问by Freewind

I'm using sbt to build scala projects, but it always seems too complex(unfamiliar) and heavy to me. I'm also using gradle to build java projects, and which makes me happy.

我正在使用 sbt 来构建 Scala 项目,但它对我来说似乎总是太复杂(不熟悉)和沉重。我也在使用 gradle 来构建 java 项目,这让我很高兴。

I wonder is it possible to use gradle to build scala projects? Is there any big scala projects that uses gradle?

我想知道是否可以使用 gradle 来构建 Scala 项目?有没有使用 gradle 的大型 Scala 项目?

Some of my friends just tell me "Never ever think of using gradle for scala project", but refused to tell me the reason.

有些朋友只是告诉我“从来没有想过在Scala项目中使用gradle”,但拒绝告诉我原因。

回答by Andreas Neumann

It's quite easy to use gradlewith Scala. We did it for a long time (team mixed of Java ,Groovy and Scala developers) and have been quite happy with it. Most things work quite well out of the box.

在 Scala 中使用gradle非常容易。我们做了很长时间(由 Java、Groovy 和 Scala 开发人员组成的团队)并且对它非常满意。大多数东西开箱即用。

More about gradle with scala: http://www.gradle.org/docs/current/userguide/scala_plugin.html

更多关于 gradle 与 scala:http: //www.gradle.org/docs/current/userguide/scala_plugin.html

There are some problems/downfalls though:

但是有一些问题/缺点:

  • Mixed code compilation when depending on Scala Code from Java in Mixed Code projects. (Some configuration and it will work, but not out of the box)
  • more configuration for Scala specific tools needed as in sbt
  • Integration of some Scala-Tools like the Scalastyleor scctis not possible yet
  • no sbt console(gradle console has not been working properly since the last time I checked)
  • adding the scala_version number to artifacts has to be added manually each time (no %%as in sbt)
  • 在混合代码项目中依赖于 Java 中的 Scala 代码时的混合代码编译。(一些配置,它会工作,但不是开箱即用的)
  • sbt 中所需的 Scala 特定工具的更多配置
  • 集成一些 Scala 工具,如Scalastylescct尚不可能
  • 没有sbt 控制台(自从我上次检查以来,gradle 控制台一直没有正常工作)
  • 每次都必须手动添加 scala_version 编号到工件(没有%%就像在 sbt 中一样)

回答by Peter Niederwieser

It's definitely possible. Gradle's Scala support is documented in the "Scala plugin" chapter in the Gradle User Guide. The plugin is used by big companies on big projects, and can be configured to use the same incremental Scala compiler as sbt. So best try for yourself and see if it fits your requirements.

绝对有可能。Gradle 的 Scala 支持记录在Gradle 用户指南的“Scala 插件”一章中。该插件被大公司用于大项目,并且可以配置为使用与 sbt 相同的增量 Scala 编译器。所以最好自己尝试一下,看看它是否符合您的要求。