Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind printing dynamic vars around evals #12

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/alembic/still.clj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388202
(copy is f))
(.toURL f)))

(defmacro with-printing-globals-reset [& body]
`(binding [*print-dup* false
*print-length* nil
*print-level* nil
*print-meta* false
*print-readably* true]
~@body))

(defn eval-in [& args]
(with-printing-globals-reset
(apply classlojure/eval-in args)))

;;; ## Still
(defonce ^{:doc "Classpath URLs for a still"}
Expand All @@ -45,9 +56,10 @@ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388202
(defn alembic-classloader
"Return a classloader for alembic to use to resolve dependencies"
[]
(doto (apply classlojure alembic-cp)
(classlojure/eval-in
`(require '[cemerick.pomegranate.aether :as ~'aether]))))
(with-printing-globals-reset
(doto (apply classlojure alembic-cp)
(eval-in
`(require '[cemerick.pomegranate.aether :as ~'aether])))))

(defn make-still
"Create an still that that can distill jars into the specified classloader."
Expand Down Expand Up @@ -78,7 +90,7 @@ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388202
(defn project-repositories
"Load project repositories from leiningen."
([still project-file]
(classlojure/eval-in
(eval-in
(:alembic-classloader @still)
`(do
(require '[leiningen.core.project :as ~'project])
Expand All @@ -90,7 +102,7 @@ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388202

(defn resolve-dependencies
[still dependencies repositories proxy]
(classlojure/eval-in
(eval-in
(:alembic-classloader @still)
`(do
(require '[leiningen.core.classpath :as ~'cp])
Expand Down Expand Up @@ -119,7 +131,7 @@ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388202
"Return a URL for the META-INF properties file for the given `coords`."
[still coords]
(let [{:keys [group-id artifact-id]} (coords->ids coords)]
(classlojure/eval-in
(eval-in
(:classloader @still)
`(when-let [r# (resource ~(properties-path group-id artifact-id))]
(.toString r#)))))
Expand All @@ -129,7 +141,7 @@ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388202
`coords`."
[still coords]
(let [{:keys [group-id artifact-id]} (coords->ids coords)]
(classlojure/eval-in
(eval-in
(:classloader @still)
`(when-let [r# (resource ~(properties-path group-id artifact-id))]
(with-open [rdr# (reader r#)]
Expand Down Expand Up @@ -287,7 +299,7 @@ for the dependencies. Loads any of the jars that are not conflicting
with versions already on the classpath."
[project-file {:keys [still verbose proxy] :as options}]
(let [[dependencies repositories]
(classlojure/eval-in
(eval-in
(:alembic-classloader @still)
`(do
(require '[leiningen.core.project :as ~'project])
Expand Down Expand Up @@ -351,10 +363,10 @@ for dependencies by the still)."
(defn lein-apply
"Invoke lein"
[args {:keys [still verbose] :as options}]
(classlojure/eval-in
(eval-in
(:alembic-classloader @still)
`(require '[leiningen.core.main]))
(classlojure/eval-in
(eval-in
(:alembic-classloader @still)
`(fn [out# err#]
(binding [leiningen.core.main/*exit-process?* false
Expand Down
6 changes: 3 additions & 3 deletions test/alembic/still_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"Return the path of a clojure jar."
[]
(let [cl (still/alembic-classloader)]
(classlojure/eval-in
(still/eval-in
cl
`(letfn [(apath# [^java.io.File f#] (.getAbsolutePath f#))]
(->
Expand Down Expand Up @@ -39,7 +39,7 @@
(map #(.toString %) (util/all-classpath-urls cl))))
(is (= [{:coords clojure-dep :current-version "1.4.0"}]
(still/current-dep-versions still [{:coords clojure-dep}])))
(is (nil? (classlojure/eval-in
(is (nil? (still/eval-in
cl
`(do
(try (require 'clojure.tools.logging)
Expand All @@ -54,7 +54,7 @@
"One dependency jar added")
(is (= 1 (count (filter :current-version deps)))
"One possible dependency conflict")
(is (classlojure/eval-in
(is (still/eval-in
cl
`(do
(require 'clojure.tools.logging)
Expand Down