Skip to content

Commit

Permalink
Fix clojure-emacs#215 : Support JVM system proxy in mvn artifacts lis…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
rinconjc committed Feb 9, 2018
1 parent 4799394 commit b4e336e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

## Unreleased

* [#215](https://github.com/clojure-emacs/refactor-nrepl/issues/215) Support JVM system proxy in mvn artifacts listing
* [#198](https://github.com/clojure-emacs/refactor-nrepl/issues/187) Delay middleware loading to speed up initialization.
* Bump [mranderson](https://github.com/benedekfazekas/mranderson) version to fix leiningen 2.8.x incompatibility issues

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Any configuration settings passed along with the message will replace the defaul
### Artifact lookup

This middleware provides operations for obtaining information about artifacts from clojars, or mvn central.
If JVM system proxy properties are defined (e.g. http.proxyHost, http.proxyPort) they will be used for downloading the artifacts.

Two ops are available:

Expand Down
12 changes: 10 additions & 2 deletions src/refactor_nrepl/artifacts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
(defonce artifacts (atom {} :meta {:last-modified nil}))
(def millis-per-day (* 24 60 60 1000))

(defn- get-proxy-opts
"Generates proxy options from JVM properties for httpkit-client "
[]
(when-let [proxy-host (some #(System/getProperty %) ["https.proxyHost" "http.proxyHost"])]
{:proxy-host proxy-host
:proxy-port (some->> ["https.proxyPort" "http.proxyPort"]
(some #(System/getProperty %)) Integer/parseInt)}))

(defn get-artifacts-from-clojars!
"Returns a vector of [[some/lib \"0.1\"]...]."
[]
Expand Down Expand Up @@ -47,7 +55,7 @@
(let [search-prefix "http://search.maven.org/solrsearch/select?q=g:%22"
search-suffix "%22+AND+p:%22jar%22&rows=2000&wt=json"
search-url (str search-prefix group-id search-suffix)
{:keys [_ _ body _]} @(http/get search-url {:as :text})
{:keys [_ _ body _]} @(http/get search-url (assoc (get-proxy-opts) :as :text))
search-result (json/parse-string body true)]
(map :a (-> search-result :response :docs))))

Expand All @@ -60,7 +68,7 @@
"%22+AND+a:%22"
artifact
"%22&core=gav&rows=200&wt=json")
{:as :text})]
(assoc (get-proxy-opts) :as :text))]
(->> (json/parse-string body true)
:response
:docs
Expand Down

0 comments on commit b4e336e

Please sign in to comment.