IntelliJ Import Dependencies - SBT Dependencies And Maven

By Nadim Bahadoor | Last updated: March 5, 2020 at 12:41 pm

Overview

In this tutorial, we will provide some additional information with regards to importing third party libraries or dependencies in our Scala application. 

 

In the previous tutorial 10, we showed how to update our build.sbt file to import a logging utility named Scala Logging. But from where did IntelliJ download the Scala Logging external library? Well the answer is Maven Central.

 

Steps

1. What is Maven Central?
Maven Central is a repository where you can find external libraries! Maven in itself provides a set of tools and utilities to help with pretty much everything regarding building and deploying our software.

 

2. How can I search Maven Central?
Fortunately, the Maven Central repository comes with a nice search functionality which allows you to find particular libraries and utilities (more commonly known as artifacts).

 

maven central repository website

 

As an example, to search for the Scala Logging utility which we used in the previous tutorial, we can enter com.typesafe.scala-logging in the search box of as shown below:

 

01 search maven repository

 

NOTE:

  • The results are categorized by GroupId, ArtifactId and Latest Version as shown above.

If you recall from the previous tutorial on importing dependencies from SBT, we've used the GroupId, Artifactid and version in our build.sbt as shown below:

 

scala logging build sbt dependency

 

NOTE:

  • Our build.sbt dependencies for Scala Logging matches the above Maven Central search:
    • Groupid was com.typesafe.scala-logging
    • Artifactid was scala-logging. We did not include the Scala version which was displayed from the Maven search results. This is because we added the %% which tells SBT to pull down the artifact which matches our Scala version.
    • Version was 3.4.0

 

3. GitHub and open source
So as shown in Step 2 above, we can easily find artifacts by doing a search from Maven Central. But what if we wanted to find more details about the Scala Logging artifact? Well the answer is GitHub!

 

If you have never heard of GitHub, please visit the GitHub homepage.

 

04_github_homepage

 

NOTE:

  • GitHub is yet another popular repository where you can view and contribute to a wide variety of open source projects.
  • GitHub should not be confused with Git version control. As per wikipedia, GitHub is a web-based Git repository hosting service, while Git is a version control similar to SVN, CVS or Perforce.

We could spend a whole chapter on Git, but for now let us search for our Scala Logging utility on GitHub:

 

github scala logging repository

 

NOTE:

  • Each project on GitHub comes with a page where you can access the source code, as well as read any other details regarding the artifact itself.

This concludes our tutorial on IntelliJ Import Dependencies - SBT Dependencies And Maven and I hope you've found it useful!

 

Stay in touch via Facebook and Twitter for upcoming tutorials.

 

Don't forget to like and share this page :)

Summary

In this article, we went over the following:

  • What is Maven Central Repository?
  • How can I search Maven Central Repository?
  • A brief introduction to GitHub

Tip

  • You can find the list of default resolvers for SBT from its documentation.

Source Code

The source code is available on the allaboutscala GitHub repository.

 

What's Next

In the next tutorial, I will show you how to create a real-world build.sbt file by structuring and organizing sections within your build.sbt file such as artifacts, settings and project.

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Technology and Finance Consultant with over 14 years of hands-on experience building large scale systems in the Financial (Electronic Trading Platforms), Risk, Insurance and Life Science sectors. I am self-driven and passionate about Finance, Distributed Systems, Functional Programming, Big Data, Semantic Data (Graph) and Machine Learning.