Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Jar libraries to an IntelliJ Idea SBT Scala project?

I've created an IntelliJ Idea SBT Scala project like Heiko Seeberger's article describes.

I'd like to add a Jar library (joda-time) to use in this project. How to do this? Simply putting them into project's /lib does not help. If I right-click "External libraries" in Idea's project tree, "New >" is greyed.

like image 803
Ivan Avatar asked Sep 25 '10 23:09

Ivan


People also ask

How do I create a JAR file in Scala code in IntelliJ?

In the Create JAR from Modules window, select the folder icon in the Main Class text box. In the Select Main Class window, select the class that appears by default and then select OK. In the Create JAR from Modules window, ensure the extract to the target JAR option is selected, and then select OK.

How do I import libraries into IntelliJ?

From the main menu, select File | Project Structure | Project Settings | Modules. Select the module for which you want to add a library and click Dependencies. button and select Library. In the dialog that opens, select a project or a global library that you want to add to the module.


2 Answers

In the IntelliJ Idea window of your project, got to File >> Project structure >> Libraries. After clicking that Libraries option, two panes will show up. At the top of the left-most pane, click the green "+" button.

like image 166
Ivan Avatar answered Oct 03 '22 22:10

Ivan


The better way to do it is to add your unmanaged dependencies to your build.sbt and refrain from leaving part of your dependency management to your IDE.

Refer to http://www.scala-sbt.org/release/docs/Library-Management.html for details on how to define your unmanagedBase and unmanagedJars tasks.

like image 26
mcyalcin Avatar answered Oct 03 '22 23:10

mcyalcin