Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

comparing sbt and Gradle [closed]

Tags:

gradle

scala

sbt

I am diving into Scala and noticed sbt. I have been quite happy with Gradle in java/groovy projects, and I know there's a scala plugin for Gradle.

What could be good reasons to favour sbt over Gradle in a Scala project?

like image 938
Hans Westerbeek Avatar asked Jun 16 '12 08:06

Hans Westerbeek


People also ask

What is Gradle and sbt?

Gradle is an open source tool with 9.23K GitHub stars and 2.7K GitHub forks. Here's a link to Gradle's open source repository on GitHub. Netflix, Lyft, and 9GAG are some of the popular companies that use Gradle, whereas SBT is used by Auto Trader, Betaout, and MD Insider.

What is better than Gradle?

Apache Maven Even IDE's can import projects and quickly understand where everything fits and how to organize it. Since Maven has been around longer than Gradle, its IDE support is far better and more extensive than its counterpart.

Is sbt better than Maven?

I recently surveyed the current state of these three tools and concluded that SBT is better suited than Maven to Scala projects' needs.


2 Answers

Note that one key difference between SBT and Gradle is its dependency management:

  • SBT: Ivy, with a a revision which can be given as a fixed one (1.5.2, for instance) or as latest (or dynamic) one.
    See "Ivy Dependency"
    That means the "-SNAPSHOT" mechanism support can be problematic, even though Mark Harrah details in this thread:

It is true the cache can get confused, but it is not true that Ivy doesn't understand resolving snapshots. Eugene explained this point in another thread, perhaps on the admin list. There is an issue with sbt's auto-update that was addressed in 0.12.

What Ivy does not support, as far as I know, is publishing snapshots in the manner Maven does. I believe I have stated this elsewhere, but if anyone wants to improve the situation, my opinion is that effort is best spent working with the Gradle team to reuse their dependency management code.

  • Gradle: This thread mentions (Peter Niederwieser):

Just to let you know, problems with Ivy and Maven snapshot dependencies were one of the reasons why Gradle eventually replaced Ivy with its own dependency management code. It was a big task, but brought us a lot of goodness.

This tweet mentions that the all situation could evolve in the future:

Mark said in the past that he was interested in using Gradle instead of Ivy for SBT.

(both tools can learn from each other)

like image 188
VonC Avatar answered Oct 05 '22 18:10

VonC


For me the key features of SBT are:

  • Fast compilation (faster than fsc).
  • Continuous compilation/testing: the command ~test will recompile and test you project everytime you save a modification.
  • Cross-compilation and cross-publishing, across several scala versions.
  • Automatically retrieving dependencies with the correct scala version compatibility.

The downsides are:

  • A hieroglyphic syntax that tends to discourage new users (especially if they come from Java)
  • No easy way to define a "task": if you need a special build procedure, you will need to either find a plugin, or write a plugin yourself.
like image 29
paradigmatic Avatar answered Oct 05 '22 18:10

paradigmatic