Skip to content

Commit b7f1528

Browse files
rinconjcbenedekfazekas
authored andcommitted
Fix #215 : Support JVM system proxy in mvn artifacts listing
1 parent 4799394 commit b7f1528

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

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

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Any configuration settings passed along with the message will replace the defaul
9696
### Artifact lookup
9797

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

100101
Two ops are available:
101102

src/refactor_nrepl/artifacts.clj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
(defonce artifacts (atom {} :meta {:last-modified nil}))
1818
(def millis-per-day (* 24 60 60 1000))
1919

20+
(defn- get-proxy-opts
21+
"Generates proxy options from JVM properties for httpkit-client "
22+
[]
23+
(when-let [proxy-host (some #(System/getProperty %) ["https.proxyHost" "http.proxyHost"])]
24+
{:proxy-host proxy-host
25+
:proxy-port (some->> ["https.proxyPort" "http.proxyPort"]
26+
(some #(System/getProperty %)) Integer/parseInt)}))
27+
2028
(defn get-artifacts-from-clojars!
2129
"Returns a vector of [[some/lib \"0.1\"]...]."
2230
[]
@@ -47,7 +55,7 @@
4755
(let [search-prefix "http://search.maven.org/solrsearch/select?q=g:%22"
4856
search-suffix "%22+AND+p:%22jar%22&rows=2000&wt=json"
4957
search-url (str search-prefix group-id search-suffix)
50-
{:keys [_ _ body _]} @(http/get search-url {:as :text})
58+
{:keys [_ _ body _]} @(http/get search-url (assoc (get-proxy-opts) :as :text))
5159
search-result (json/parse-string body true)]
5260
(map :a (-> search-result :response :docs))))
5361

@@ -60,7 +68,7 @@
6068
"%22+AND+a:%22"
6169
artifact
6270
"%22&core=gav&rows=200&wt=json")
63-
{:as :text})]
71+
(assoc (get-proxy-opts) :as :text))]
6472
(->> (json/parse-string body true)
6573
:response
6674
:docs

0 commit comments

Comments
 (0)