Why is Coursier needed? What is the different between coursier and maven, sbt, gradle?

620 Views Asked by At

The documentation says that coursier is a new artifact manager for scala. But what is the difference between Coursier and build tools like maven, sbt and gradle? Why do I need +1 folder with jar files? I have already .m2 for maven repository, .gradle for gradle, and .sbt for sbt. So I built some project and now I have AppData/Local/Coursier with "same" jar files. Could somebody explain what is the goal for Coursier project?

1

There are 1 best solutions below

0
On

You are confusing a build tool like sbt and Maven and Gradle and Ant, with an artifact manager like coursier and ivy.

AFAIK (please correct me if wrong), before coursier was invented, sbt used ivy to download the JAR files from repositories like MavenCentral.
After that, coursier was invented to be both faster and better handle Scala dependencies (the versions suffixes and all that). I am not really sure what are the technical differences, but I really don't care since it is an implementation detail.
Then, newer versions of sbt simply switched from using ivy to use coursier, and the biggest difference was that it was now faster at downloading things, and that the cache folder changed.

With time, over the coursier bare artifact manager, other things have been built like the cs tool, scala-cli, the GithubActions shared actions like coursier/setup-scala & coursier/cache. Thus, as of today, everything works together seamlessly.

About the duplicated JAR's folders. Unless you are using both sbt and maven with shared dependencies between both, you should be able to just delete the old .m2 folder.