/intellij-leiningen-plugin

A plugin for JetBrains' IntelliJ IDE supporting the Leiningen build system.

Primary LanguageJava

The IntelliJ Leiningen Plugin

This plugin integrates Leiningen into IntelliJ. It is supposed to work with both the Ultimate and Community Edition
of IntelliJ.

Features

  • Import leiningen projects into IntelliJ IDEA.
  • Directly open a leiningen project file (just like you can open maven POMs).
  • Dependencies from the leiningen project file are set up as libraries in IntelliJ.
  • Run the mostly used actions (like compile, jar, uberjar, etc.) with a single click.
  • Create run configurations for less used or parametrized actions.

Usage

Install the plugin via the plugin manager of IntelliJ. Then go to Settings > Leiningen and set up the location of
Leiningen. Now you can run Leiningen targets in the Leiningen tool window on the right side of the IntelliJ main
window by doubleclicking on the target name.

When you open a project that has a project.clj file in it’s root, it is automatically added to the list of
Leiningen projects in the Leiningen tool window. If you have multiple project.clj files in your project tree (e.g. a
project with subprojects) you can add these manually by pressing the plus icon in the Leiningen tool window.

Compiling the source code

  • Grab the latest version from http://github.com/derkork/intellij-leiningen-plugin.
  • Setup an IntelliJ SDK
    • I suggest using an IntelliJ Community Edition as SDK base, to ensure that the plugin will run on the Community Edition as well.
  • Create a new project from scratch and add a Plugin Module which points at the root directory of the intellij-leiningen-plugin source.
    • When it asks for a Project SDK, point it at the Community Edition SDK you have just set up.
    • Once the project and module have been created:
      • Add the resources directory as a source root to the plugin module.
      • Add the test directory as a test root to the plugin module.
  • Setup the dependency on the leiningen interop library which is written in Clojure:
    • Using leiningen 2.0 or higher, navigate on the command line to the interop subdirectory
      • Run ‘lein uberjar’ – this will generate a standalone jar file.
      • Add this jar to the plugin module’s dependency list
  • Add a new Plugin Run Configuration to the project and tell it to use the classpath of your plugin module
    • Run the plugin using the configuration you just created!

Adding the interop directory as a module.

If you wish to add the interop module to the project do the following:

  • Using leiningen 2.0 or higher, navigate on the command line to the interop subdirectory
    • Run ‘lein pom’ – this will generate a pom.xml file.
  • Navigate to the pom.xml file in IDEA’s project manager
  • Right click on the pom.xml – Select ‘Add as Maven Project’
    • Maven plugin needs to be enabled for this
    • This will create a module named interop in your project
    • Add this module as a module dependency to the plugin module.

Building the plugin distribution

To build a deployable Jar file:

  • From the program menus, select Build → Prepare plugin-module [plugin-module-name] for Deployment.
    • This will create a Jar file that you can deploy into your IntelliJ plugins folder.

Submitting patches

Patches can be submitted via email to janthomae at janthomae dot de or using GitHub’s fork and pull request facility.