diff --git a/src/lein_monolith/task/each.clj b/src/lein_monolith/task/each.clj index d61b32c..86c6671 100644 --- a/src/lein_monolith/task/each.clj +++ b/src/lein_monolith/task/each.clj @@ -165,8 +165,12 @@ (when-not *task-file-output* (throw (IllegalStateException. (str "Cannot run task without bound *task-file-output*: " (pr-str cmd))))) - (let [env (@#'eval/overridden-env eval/*env*) - ^Process proc (.exec (Runtime/getRuntime) (into-array String cmd) env (io/file eval/*dir*))] + (let [cmd (into-array String cmd) + env (into-array String (@#'eval/overridden-env eval/*env*)) + proc (.exec (Runtime/getRuntime) + ^{:tag "[Ljava.lang.String;"} cmd + ^{:tag "[Ljava.lang.String;"} env + (io/file eval/*dir*))] (.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (.destroy proc)))) (with-open [out (.getInputStream proc) @@ -187,6 +191,13 @@ exit-value))))) +(def ^:private init-lock + "An object to lock on to ensure that projects are not initialized + concurrently. This prevents the mysterious 'unbound fn' errors that sometimes + crop up during parallel execution." + (Object.)) + + (defn- apply-subproject-task "Applies the task to the given subproject." [monolith subproject task] @@ -198,7 +209,8 @@ (fn inject-profile [p k v] (assoc-in p [:profiles k] v)) subproject inherited) (config/debug-profile "init-subproject" - (project/init-project subproject (cons :default (keys inherited)))) + (locking init-lock + (project/init-project subproject (cons :default (keys inherited))))) (config/debug-profile "apply-task" (binding [eval/*dir* (:root subproject)] (lein/resolve-and-apply subproject task)))))))