Juli 13, 2012

Utilizing Leiningen Profile

In my previous post about setting up Emacs for Clojure development, I suggest to include lein-swank inside the plugins' project.clj. Eventhough this approach work, here I will explain how to use Leiningen profile to separate the plugins / libraries which will act as helper and with other plugins / libraries which will be included in the project result. You will find that separation of concerns is beatiful.

Ok, now here's the problem. I would like to use lein-swank for my development with Emacs but I don't want to interfere my project with all of those clutters, I just want my project to include my source code and my libraries. This is where Leiningen profile comes into play. To this end, use profile.clj inside Leiningen home (that is $HOME/.lein/). The default profile which will be executed is "user". Here is mine:

[bpdp@bpdp-arch ~]$ tree .lein/
|-- profiles.clj
`-- self-installs   
     |-- leiningen-1.7.1-standalone.jar   
      `-- leiningen-2.0.0-preview7-standalone.jar
1 directory, 3 files[bpdp@bpdp-arch ~]$ 

Here's the profile.clj content:

[bpdp@bpdp-arch .lein]$ cat profiles.clj 
{:user {:plugins [[lein-swank "1.4.4"]
                         [lein-pprint "1.1.1"]]}}
[bpdp@bpdp-arch .lein]$ 

This way, you can - for example - execute lein-swank without include them in your project.clj anymore. You may add other plugins. I just use lein-pprint in the meantime. There are still many things that can be done using this profile, for example, you can use this profile to test multiversion plugins / libraries, etc. I will write them later.

Happy hacking!


Poskan Komentar