Clojure Leiningen その3

ライブラリの検索について

vagrant@ubuntu2204:~/source/temp$ lein search clj-http
Searching central ...
[pro.juxt.clojars-mirrors.clj-http/clj-http "3.12.2"]
Searching clojars ...
[clj-http "3.12.3"]
  A Clojure HTTP library wrapping the Apache HttpComponents client.
[clj-http-fake "1.0.3"]
  Helper for faking clj-http requests in testing, like Ruby's fakeweb.
[org.sharetribe/aws-sig4 "0.1.4"]
  Middleware to add AWS signature v4 signing to clj-http requests.
[clj-oauth2 "0.2.0"]
  clj-http and ring middlewares for OAuth 2.0
[clj-http-hystrix "0.1.6"]
  A Clojure library to wrap clj-http requests as hystrix commands
[martian-clj-http "0.1.17-SNAPSHOT"]
  clj-http implementation for martian
[stuarth/clj-oauth2 "0.3.2"]
  clj-http and ring middlewares for OAuth 2.0
[org.clojars.osbert/clj-oauth2 "0.1.9"]
  clj-http and ring middlewares for OAuth 2.0
[b-ryan/clj-http-mock "0.6.0"]
  Mock responses to clj-http requests.
[org.clj-commons/clj-http-lite "1.0.13"]
  A lite version of clj-http that uses the jre's HttpURLConnection
[clj-http-mock "0.4.0"]
  Mock responses to clj-http requests.
[onaio/clj-oauth2 "0.3.2"]
  clj-http and ring middlewares for OAuth 2.0
[wkf/clj-http "2.0.0"]
  A Clojure HTTP library wrapping the Apache HttpComponents client.
[com.gfredericks.forks.clj-http-fake/clj-http-fake "1.0.3-37e38b42"]
  Helper for faking clj-http requests. For testing. You monster.
[com.github.oliyh/martian-clj-http "0.1.22-SNAPSHOT"]
  clj-http implementation for martian
[opentable/clj-http "3.0.0-beta-1"]
  A Clojure HTTP library wrapping the Apache HttpComponents client.
[mavericklou/clj-oauth2 "0.5.2"]
  clj-http and ring middlewares for OAuth 2.0
[twosigma/clj-http "3.9.1-ts2"]
  A Clojure HTTP library wrapping the Apache HttpComponents client.
[thirtyspokes/hindrance "1.1.0"]
  A convenience wrapper for using OAuth JWT credentials flow with clj-http.
[racehub/clj-http "1.0.1"]
  A Clojure HTTP library wrapping the Apache HttpComponents client.
[org.clojars.ub-hyleung/clj-http-mock "0.5.0"]
  Mock responses to clj-http requests.
[com.farmlogs/looper "0.3.0"]
  Drop-in clj-http replacement with retries
[emil0r/clj-oauth2 "0.6.0"]
  clj-http and ring middlewares for OAuth 2.0 [fork]
[sudharsh/clj-oauth2 "0.5.3"]
  clj-http and ring middlewares for OAuth 2.0

依存関係の定義について

  • 依存関係の定義は project.clj:dependencies ベクターで行う。
  • :dependencies には [<グループID/アーティファクトID> "<バージョン>"] と書く。(Mavenと同じ感覚。)
  • グループIDとアーティファクトIDが同じであれば、2つ書く必要がなく、グループIDを省略していい。
  • 例えば clj-http の場合はグループIDとアーティファクトIDが同じなので [clj-http "3.12.3"] と書ける。
  • leinは :dependencies を見て、依存先をダウンロードする。
  • 明示的にダウンロードしたい場合は lein deps コマンドを使う。

やってみる

  • clj-http を依存先に追加してみる。
  :dependencies [[org.clojure/clojure "1.11.1"]
                 [clj-http "3.12.3"]]
  • lein depsclj-http をダウンロードする。
vagrant@ubuntu2204:~/source/temp$ lein deps
Retrieving clj-http/clj-http/3.12.3/clj-http-3.12.3.pom from clojars
Retrieving org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-core/4.4.14/httpcomponents-core-4.4.14.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-parent/11/httpcomponents-parent-11.pom from central
Retrieving org/apache/apache/21/apache-21.pom from central
Retrieving org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-client/4.5.13/httpcomponents-client-4.5.13.pom from central
Retrieving org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-core/4.4.13/httpcomponents-core-4.4.13.pom from central
Retrieving org/apache/httpcomponents/httpclient-cache/4.5.13/httpclient-cache-4.5.13.pom from central
Retrieving org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-asyncclient/4.1.4/httpcomponents-asyncclient-4.1.4.pom from central
Retrieving org/apache/httpcomponents/httpcore/4.4.10/httpcore-4.4.10.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-core/4.4.10/httpcomponents-core-4.4.10.pom from central
Retrieving org/apache/httpcomponents/httpcore-nio/4.4.10/httpcore-nio-4.4.10.pom from central
Retrieving org/apache/httpcomponents/httpclient/4.5.6/httpclient-4.5.6.pom from central
Retrieving org/apache/httpcomponents/httpcomponents-client/4.5.6/httpcomponents-client-4.5.6.pom from central
Retrieving org/apache/httpcomponents/httpmime/4.5.13/httpmime-4.5.13.pom from central
Retrieving commons-codec/commons-codec/1.15/commons-codec-1.15.pom from central
Retrieving org/apache/commons/commons-parent/52/commons-parent-52.pom from central
Retrieving org/apache/apache/23/apache-23.pom from central
Retrieving commons-io/commons-io/2.8.0/commons-io-2.8.0.pom from central
Retrieving org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.jar from central
Retrieving org/apache/httpcomponents/httpclient-cache/4.5.13/httpclient-cache-4.5.13.jar from central
Retrieving org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar from central
Retrieving org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.jar from central
Retrieving org/apache/httpcomponents/httpcore-nio/4.4.10/httpcore-nio-4.4.10.jar from central
Retrieving org/apache/httpcomponents/httpmime/4.5.13/httpmime-4.5.13.jar from central
Retrieving commons-codec/commons-codec/1.15/commons-codec-1.15.jar from central
Retrieving commons-io/commons-io/2.8.0/commons-io-2.8.0.jar from central
Retrieving clj-http/clj-http/3.12.3/clj-http-3.12.3.jar from clojars

外部リポジトリについて

  • 検索同様、leinはMavenCentral、Clojarから依存ライブラリを取得する。
  • MavenCentralはご存知の通り、Javaの主なライブラリが置いてある。
  • Clojarは主にClojurコミュニティが集中してライブラリを配置している。
  • その他のリポジトリを参照する場合は、project.cljの :repositories で設定する。
  • sample.project.clj が参考になる。