IntelliJ Import Dependencies - SBT Dependencies And Maven

By Nadim Bahadoor | Last updated: July 14, 2017 at 12:28 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 IntelliJ's Settings screen which is important to get familiar with as it will help you with every aspect of building Scala applications.

Nadim Bahadoor on FacebookNadim Bahadoor on GithubNadim Bahadoor on LinkedinNadim Bahadoor on Twitter
Nadim Bahadoor
Senior Software Developer | Elsevier
Founder of allaboutscala.com. I have over 10 years of experience in building large scale real-time trading systems in the financial industry. Passionate about Distributed Systems, Scala, Big Data and Functional Programming. Stay in touch for upcoming tutorials!

Share this article on

  • Tree_Ed

    This is the best tutorial for scala I have ever found! Thanks Bahadoor.
    And hope to see Spark tutorial to be finished soon!

    • allaboutscala

      Hi Tree_Ed, thank you for your kind words and I’m glad to hear that you are finding the tutorials useful. I hope to publish some of the Spark tutorials in the coming weeks. -Cheers,Nadim.

  • Vic Kirkpatrick

    I have to concur with Tree_Ed on that compliment. Especially appreciated is that you take into account the true beginner, not taking for granted anything that we might already know. I have been doing database development for 30 years, and wanted to get to know scala on my way to getting to know spark. These tutorials are excellent and thanks Nadim!

    • allaboutscala

      Hi Vic,
      Thank you for your kind note. Don’t be shy at sharing my blog to your friends and colleagues! I have recently added a number of tutorials on Spark (DataFrame, SQL and Statistics) http://allaboutscala.com/big-data/spark/ I hope you will find these useful as well. Soon more to follow on DataFrame operations and Machine Learning pipeline.
      Cheers,
      Nadim