Permalink
Browse files

Support picking up :dependencies from profiles in trampoline task.

Fixes #695.
Fixes #732.
  • Loading branch information...
1 parent fc7e3c7 commit d76f79604772a765a696bc45512c0c1c2c0e3f9c @technomancy committed Aug 16, 2012
Showing with 14 additions and 9 deletions.
  1. +2 −1 leiningen-core/src/leiningen/core/eval.clj
  2. +12 −8 src/leiningen/trampoline.clj
@@ -169,7 +169,8 @@
(throw (ex-info "Subprocess failed" {:exit-code exit-code}))))))
(defmethod eval-in :trampoline [project form]
- (swap! (:trampoline-forms (meta project)) conj form))
+ (swap! (:trampoline-forms (meta project)) conj form)
+ (swap! (:trampoline-deps (meta project)) conj (:dependencies project)))
(defmethod eval-in :classloader [project form]
(let [classpath (map io/file (classpath/get-classpath project))
@@ -3,6 +3,7 @@
(:require [clojure.string :as string]
[leiningen.core.eval :as eval]
[leiningen.core.main :as main]
+ [leiningen.core.project :as project]
[clojure.pprint :as pprint]))
(def ^:dynamic *trampoline?* false)
@@ -13,21 +14,24 @@
(defn- quote-arg [arg]
(format "\"%s\"" arg))
-(defn trampoline-command-string [project forms]
+(defn trampoline-command-string [project forms deps]
;; each form is (do init & body)
(let [forms (map rest forms) ;; strip off do
inits (map first forms)
rests (mapcat rest forms)
- ;; TODO: tasks that assoc :dependencies in will not be honored here
+ ;; This won't pick up :jvm-args that come from profiles, but it
+ ;; at least gets us :dependencies.
+ project (project/normalize-deps (update-in project [:dependencies]
+ (partial apply concat) deps))
command (eval/shell-command project (concat '(do) inits rests))]
(string/join " " (if (win-batch?)
(map quote-arg command)
(conj (vec (map quote-arg (butlast command)))
(with-out-str
(prn (last command))))))))
-(defn write-trampoline [project forms]
- (let [command (trampoline-command-string project forms)]
+(defn write-trampoline [project forms deps]
+ (let [command (trampoline-command-string project forms deps)]
(main/debug "Trampoline command:" command)
(spit (System/getProperty "leiningen.trampoline-file") command)))
@@ -40,14 +44,14 @@ than as a subprocess of Leiningen's project.
Use this to save memory or to work around stdin issues."
[project task-name & args]
- ;; TODO: allow trampoline calls to chain with do (does this already work?)
- (let [forms (atom [])]
+ (let [forms (atom []), deps (atom [])]
(when (:eval-in-leiningen project)
(main/info "Warning: trampoline has no effect with :eval-in-leiningen."))
(binding [*trampoline?* true]
(main/apply-task (main/lookup-alias task-name project)
(with-meta (assoc project :eval-in :trampoline)
- {:trampoline-forms forms}) args))
+ {:trampoline-forms forms
+ :trampoline-deps deps}) args))
(if (seq @forms)
- (write-trampoline project @forms)
+ (write-trampoline project @forms @deps)
(main/abort task-name "did not run any project code for trampolining."))))

0 comments on commit d76f796

Please sign in to comment.