Skip to content

Using Boot in a Leiningen Project

Chris Truter edited this page Jan 8, 2016 · 8 revisions

The from-lein task below will setup basic environment parameters taken from a project.clj for Boot. This makes it possible to run things like:

  • boot from-lein watch build-jar
  • boot from-lein build-jar, etc.

If you want to override settings make sure you do so after calling the from-lein task.

(def boot-version
  (get (boot.App/config) "BOOT_VERSION" "2.5.5"))

(deftask from-lein
  "Use project.clj as source of truth as far as possible"
  []
  (let [lein-proj (let [l (-> "project.clj" slurp read-string)]
                    (merge (->> l (drop 3) (partition 2) (map vec) (into {}))
                           {:project (second l) :version (nth l 2)}))]
    (merge-env! :repositories (:repositories lein-proj))
    (set-env!
      :certificates   (:certificates lein-proj)
      :source-paths   (or (:source-paths lein-proj) #{"src"})
      :resource-paths (or (:resource-paths lein-proj) #{})
      :dependencies   (into (:dependencies lein-proj)
                            `[[boot/core ~boot-version   :scope "provided"]
                              [adzerk/bootlaces "0.1.13" :scope "test"]]))

    (require '[adzerk.bootlaces :refer :all])
    ((resolve 'bootlaces!) (:version lein-proj))
    (task-options!
      repl (:repl-options lein-proj {})
      aot  {:namespace (:aot lein-proj) :all (not (:aot lein-proj))}
      pom  {:project     (symbol (:project lein-proj))
            :version     (:version lein-proj)
            :description (:description lein-proj)
            :url         (:url lein-proj)
            :scm         {:url "https://github.com/martinklepsch/boot-gzip"}
            :license     (get lein-proj :license 
                              {"EPL" "http://www.eclipse.org/legal/epl-v10.html"})}))
  identity)
Clone this wiki locally