Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sometimes you want to use boot as a scripting platform on top of Leinengen. Paste this code at the top of your build.boot file. It reads in the project.clj file and stores it as a map named "project" which you can then use with `set-env!` to setup your environment.
(set-env! :dependencies '[[leiningen-core "2.5.0"]])
(use 'leiningen.core.project)
(eval (read-string (slurp "project.clj")))
:source-paths (:source-paths project)
:resource-paths (:resource-paths project)
:dependencies (:dependencies project))
;; Line 9 will replace the dependencies vector from line 1. If you want to merge them,
;; you might need to do #(into % (:dependencies project)) or something like that.
Copy link

clows commented May 1, 2015

Above approach does load quite a few dependencies that conflict with other libraries being loaded.

This snipped has no outside dependencies and does pretty much the same thing (assuming you have a rather simple project.clj (It is not very robust)

  (def lein-proj 
    (drop 3) 
    (partition 2) 
    (map vec) 
    (into {})))

 :source-paths   (into #{} (:source-paths lein-proj))
 :resource-paths (into #{} (:resource-paths lein-proj))
 :dependencies   (into [] (:dependencies lein-proj)))

Copy link

martinklepsch commented Jun 19, 2015

I made this into a task and added it to the Boot wiki:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment