How to prepare dependencies before playing Intellij Idea repl?

Let's say I want to play with some clojure library, but inside Intellij Idea's REPL. How to start preparing REPL? Or for that matter, how do I load this library anyway, even after the start?

+4
source share
2 answers

With IntelliJ, library directories within a project can be included in the Java class path that was used when running REPL. They can then be used in the REPL through Clojure "use" or "require".

The easiest way to get libraries in a project is through the Leiningen and IntelliJ Leiningen plugins. Leiningen is a build and dependency management tool for Clojure.

Download and install Leiningen. Install the IntelliJ Leiningen plugin. Open the IntelliJ configuration screen and in the IDE Settings> Leiningen section, enter the path to the Leiningen executable.

In the IntelliJ project window, create a Clojure file called project.clj in the root. Edit this file using Leiningen syntax to determine which libraries the project depends on. Use the Leiningen library name from the library entry on clojars.org (the main Clojure library repository) or the project web page.

In the Leiningen plug-in menu, add (+ icon) project.clj. Now on the Leiningen plug-in screen, click on the project name to open its tree, select the β€œdeps” option and click the β€œplay” icon in the menu. This will force Leiningen to load the libraries and put them in the correct (/ lib) folder of the project.

Now right-click the project name in the project windows, select "Open Module Settings"> "Modules"> "Dependencies"> "Add"> "Library"> "Name" (enter a name)> "Attach Jar Files" ("Select / lib ")

Then run REPL, load the library using "use" or "require" and everything will be installed.

+7
source

I wanted to comment on NielsK's answer, but I can't for some reason ... make sure Maven is included in the IDE anyway, as leiningen creates a POM that IDEA uses to import dependencies.

+1
source

All Articles