Working with Leiningen

Leiningen is the de-facto project management tool for Clojure. Cursive provides great support for building and managing projects with Leiningen, and we’ll be adding more functionality soon.

Import an existing Leiningen project

Select File→New→Project from Existing Sources… and select the project you would like to import. You can select either the project.clj or the directory containing it.

If required, select “Import project from external model” and select Leiningen.

The root directory of your project will be filled in for you. You can choose to search recursively within that directory for other projects (see Multi Module Projects, below), and you can also choose to put the project files in a directory other than the main project directory.

You will then be presented with a list of the Leiningen projects found, and you can select which to import.

Pick an SDK, then confirm your project name and file locations.

Your project will then be opened and is ready to use.

Coming Soon: We’ll be allowing more fine-grained use of profiles during this process.

Working with your Leiningen project

The Leiningen tool window shows the currently active Leiningen projects, and presents you with a list of the most common tasks to run.

Coming Soon: We’ll be reading the list of available tasks from the project which will include tasks provided by plugins.

You can select a task and run it using the icon in the tool window toolbar.

The and icons allow you to add and remove Leiningen projects to and from your IntelliJ project (see Multi Module Projects below).

Refreshing Leiningen dependencies

When you have updated your project.clj file, you can press the icon to re-read the project file and refresh the project dependencies. Note that this is not performed automatically when the project.clj is updated, unlike the Maven plugin. The project may also be refreshed before starting a REPL by adding “Synchronize Leiningen Projects” to the Before Launch section of its run configuration.

Quick project import

For simple projects you don’t need to explicitly import them. Just use File→Open… as normal, select either the project.clj or the containing directory, and your project will be automatically imported.

Create a new project using Leiningen

  • This is coming soon.
  • As a workaround, use lein new on the command line and then import as above.

Working with multi-module projects

If you have a more complex project with multiple modules, Cursive will detect it automatically and set everything up. When importing, make sure you check “Search for projects recursively”.

Select the projects you would like to import from the list of discovered projects. Their location within the project is displayed along with the artifact details.

And your project will be set up. An IntelliJ Module will be created for each Leiningen module, and dependencies between them and the appropriate library dependencies will be set up as well.

You can then add new modules to the project using either the button in the Leiningen tool window, or using the context menu in the project tool window. You can remove Leiningen modules from the project and optionally remove the corresponding IntelliJ module using the in the Leiningen tool window.

Checkout Dependencies

Leiningen’s standard mechanism for managing multi-module projects is to use Checkout Dependencies. Cursive fully supports checkout dependencies and will add the appropriate modules and dependencies automatically.