Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access the project map from a leiningen plugin?

Let's say I create a new leiningen project and edit the project.clj file so it looks something like the following.

(defproject foobar "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 ...
                 [clj-webmaster-tools "0.1.0"]]
  :plugins [[lein-ring "0.8.6"]
            [lein-webmaster-tools "0.1.0"]
  :webmaster {:sitemap "http://www.foobar.com/sitemap-index.xml" :robots "http://www.foobar.com/robots.txt"})

My question is, how do I access the :webmaster key in the project map for use in a leningen plugin I'm writing?

like image 586
Levi Campbell Avatar asked Aug 25 '13 15:08

Levi Campbell


1 Answers

When you write a plugin, the first parameter passed to your plugin function is the project map. It's a standard Clojure persistent map, so you can access it like any other map, i.e.

(defn my-plugin[project] 
  (println (:webmaster project)))
like image 111
noahlz Avatar answered Nov 10 '22 01:11

noahlz