diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 0a3627a2..c68d7369 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -773,40 +773,45 @@ Use bb run --help to show this help output. _ (when jar (cp/add-classpath jar)) load-fn (fn [{:keys [:namespace :reload]}] - (or (when-let [{:keys [:loader]} - @cp/cp-state] - (if ;; ignore built-in namespaces when uberscripting, unless with :reload - (and uberscript - (not reload) - (or (contains? namespaces namespace) - (contains? sci-namespaces/namespaces namespace))) - "" - (when-let [res (cp/source-for-namespace loader namespace nil)] - (if uberscript - (do (swap! uberscript-sources conj (:source res)) - (uberscript/uberscript {:ctx @common/ctx - :expressions [(:source res)]}) - {}) - res)))) - (if-let [pod (get @pod-namespaces namespace)] - (if uberscript - (do - (swap! uberscript-sources conj - (format - "(babashka.pods/load-pod '%s \"%s\" '%s)\n" - (:pod-spec pod) (:version (:opts pod)) - (dissoc (:opts pod) - :version :metadata))) - {}) - (pods/load-pod (:pod-spec pod) (:opts pod))) - (case namespace - clojure.spec.alpha - (binding [*out* *err*] - (println "[babashka] WARNING: Use the babashka-compatible version of clojure.spec.alpha, available here: https://github.com/babashka/spec.alpha")) - clojure.core.specs.alpha - (binding [*out* *err*] - (println "[babashka] WARNING: clojure.core.specs.alpha is removed from the classpath, unless you explicitly add the dependency.")) - nil)))) + (let [{:keys [loader]} + @cp/cp-state] + (or + (when ;; ignore built-in namespaces when uberscripting, unless with :reload + (and uberscript + (not reload) + (or (contains? namespaces namespace) + (contains? sci-namespaces/namespaces namespace))) + "") + ;; pod namespaces go before namespaces from source, + ;; unless reload is used + (when-not reload + (when-let [pod (get @pod-namespaces namespace)] + (if uberscript + (do + (swap! uberscript-sources conj + (format + "(babashka.pods/load-pod '%s \"%s\" '%s)\n" + (:pod-spec pod) (:version (:opts pod)) + (dissoc (:opts pod) + :version :metadata))) + {}) + (pods/load-pod (:pod-spec pod) (:opts pod))))) + (when loader + (when-let [res (cp/source-for-namespace loader namespace nil)] + (if uberscript + (do (swap! uberscript-sources conj (:source res)) + (uberscript/uberscript {:ctx @common/ctx + :expressions [(:source res)]}) + {}) + res))) + (case namespace + clojure.spec.alpha + (binding [*out* *err*] + (println "[babashka] WARNING: Use the babashka-compatible version of clojure.spec.alpha, available here: https://github.com/babashka/spec.alpha")) + clojure.core.specs.alpha + (binding [*out* *err*] + (println "[babashka] WARNING: clojure.core.specs.alpha is removed from the classpath, unless you explicitly add the dependency.")) + nil)))) main (if (and jar (not main)) (when-let [res (cp/getResource (cp/loader jar) diff --git a/test/babashka/deps_test.clj b/test/babashka/deps_test.clj index 397a01f9..d3edade2 100644 --- a/test/babashka/deps_test.clj +++ b/test/babashka/deps_test.clj @@ -35,6 +35,7 @@ (bb (pr-str `(do (babashka.deps/add-deps '{:deps {babashka/process {:git/url "https://github.com/babashka/process" :sha "4c6699d06b49773d3e5c5b4c11d3334fb78cc996"}}} {:force true :env {"PATH" (System/getenv "PATH") + "JAVA_HOME" (System/getenv "JAVA_HOME") "GITLIBS" ~(str libs-dir)}}) nil))) (bb (pr-str `(do (babashka.deps/add-deps '{:deps {babashka/process {:git/url "https://github.com/babashka/process" :sha "4c6699d06b49773d3e5c5b4c11d3334fb78cc996"}}} {:force true @@ -86,6 +87,7 @@ true libs-dir2 (fs/file tmp-dir ".gitlibs2") template (pr-str '(do (babashka.deps/clojure ["-Sforce" "-Spath" "-Sdeps" "{:deps {babashka/process {:git/url \"https://github.com/babashka/process\" :sha \"4c6699d06b49773d3e5c5b4c11d3334fb78cc996\"}}}"] {:out :string :env-key {"PATH" (System/getenv "PATH") + "JAVA_HOME" (System/getenv "JAVA_HOME") "GITLIBS" :gitlibs}}) nil))] (bb (-> template (str/replace ":gitlibs" (pr-str (str libs-dir))) (str/replace ":env-key" ":env")))