lucid.aether wrapper for org.eclipse.aether

Author: Chris Zheng  (z@caudate.me)
Date: 14 March 2017
Repository: https://www.github.com/zcaudate/lucidity
Version: 1.3.6

1    Introduction

lucid.aether is used to as an interface to manage dependencies. It is meant to replace pomegranate for package installation, dependency resolution and other tasks

Add to project.clj dependencies:

[im.chit/lucid.aether "1.3.6"]

All functionality is in the lucid.aether namespace:

(use 'lucid.aether)

2    API



aether ^

creates an `Aether` object

v 1.1
(defn aether
  ([] (aether {}))
  ([config]
   (let [system  (system/repository-system)
         session (->> (select-keys config [:local-repo])
                      (session/session system))]
     (-> +defaults+
         (merge {:system system
                 :session session})
         (map->Aether)))))
link
(aether) => (contains {:repositories [{:id "clojars", :type "default", :url "https://clojars.org/repo"} {:id "central", :type "default", :url "https://repo1.maven.org/maven2/"}], :system org.eclipse.aether.RepositorySystem :session org.eclipse.aether.RepositorySystemSession})

deploy-artifact ^

deploys artifacts to the given coordinate

v 1.2
(defn deploy-artifact
  ([coord {:keys [artifacts repository] :as opts}]
   (deploy-artifact (base/aether) coord opts))
  ([{:keys [system session]} coord {:keys [artifacts repository] :as opts}]
   (let [opts (populate-artifact coord opts)
         request (request/deploy-request opts)]
     (.deploy system session request))))
link
(deploy-artifact '[im.chit/hara.io.classpath "2.4.8"] {:artifacts [{:file "hara_io_classpath-2.4.8.jar" :extension "jar"} {:file "hara_io_classpath-2.4.8.pom" :extension "pom"} {:file "hara_io_classpath-2.4.8.pom.asc" :extension "pom.asc"} {:file "hara_io_classpath-2.4.8.jar.asc" :extension "jar.asc"}] :repository {:id "clojars" :url "https://clojars.org/repo/" :authentication {:username "zcaudate" :password "hello"}}})

install-artifact ^

installs artifacts to the given coordinate

v 1.2
(defn install-artifact
  ([coord {:keys [artifacts] :as opts}]
   (install-artifact (base/aether) coord opts))
  ([{:keys [system session]} coord {:keys [artifacts] :as opts}]
   (let [opts (populate-artifact coord opts)
         request (request/install-request opts)]
     (-> (.install system session request)
         (result/summary)))))
link
(install-artifact '[im.chit/hara.io.classpath "2.4.8"] {:artifacts [{:file "hara_io_classpath-2.4.8.jar" :extension "jar"} {:file "hara_io_classpath-2.4.8.pom" :extension "pom"}]})

resolve-dependencies ^

resolves maven dependencies for a set of coordinates

v 1.1
(defn resolve-dependencies
  ([coords]
   (resolve-dependencies (base/aether) coords))
  ([aether coords]
   (->> (resolve-hierarchy aether coords)
        (request/flatten-values)
        (sort)
        (reverse)
        (reduce (fn [out coord]
                  (if (-> out last first (= (first coord)))
                    out
                    (conj out coord)))
                []))))
link
(resolve-dependencies '[prismatic/schema "1.1.3"]) => '[[prismatic/schema "1.1.3"]] (resolve-dependencies '[midje "1.6.3"]) => '[[utilize/utilize "0.2.3"] [swiss-arrows/swiss-arrows "1.0.0"] [slingshot/slingshot "0.10.3"] [org.clojure/tools.namespace "0.2.4"] [org.clojure/tools.macro "0.1.5"] [org.clojure/math.combinatorics "0.0.7"] [org.clojure/core.unify "0.5.2"] [org.clojars.trptcolin/sjacket "0.1.3"] [ordered/ordered "1.2.0"] [net.cgrand/regex "1.1.0"] [net.cgrand/parsley "0.9.1"] [midje/midje "1.6.3"] [joda-time/joda-time "2.2"] [gui-diff/gui-diff "0.5.0"] [dynapath/dynapath "0.2.0"] [commons-codec/commons-codec "1.9"] [colorize/colorize "0.1.1"] [clj-time/clj-time "0.6.0"]]

resolve-hierarchy ^

shows the dependency hierachy for all packages

v 1.1
(defn resolve-hierarchy
  ([coords]
   (resolve-hierarchy (base/aether) coords))
  ([{:keys [system session repositories]} coords]
   (let [request (request/dependency-request
                  {:root {:artifact coords}
                   :repositories repositories})]
     (-> (.resolveDependencies system session request)
         (result/summary)))))
link
(resolve-hierarchy '[midje "1.6.3"]) => '{[midje/midje "1.6.3"] [{[ordered/ordered "1.2.0"] []} {[org.clojure/math.combinatorics "0.0.7"] []} {[org.clojure/core.unify "0.5.2"] []} {[utilize/utilize "0.2.3"] [{[org.clojure/tools.macro "0.1.1"] []} {[joda-time/joda-time "2.0"] []} {[ordered/ordered "1.0.0"] []}]} {[colorize/colorize "0.1.1"] []} {[org.clojure/tools.macro "0.1.5"] []} {[dynapath/dynapath "0.2.0"] []} {[swiss-arrows/swiss-arrows "1.0.0"] []} {[org.clojure/tools.namespace "0.2.4"] []} {[slingshot/slingshot "0.10.3"] []} {[commons-codec/commons-codec "1.9"] []} {[gui-diff/gui-diff "0.5.0"] [{[org.clojars.trptcolin/sjacket "0.1.3"] [{[net.cgrand/regex "1.1.0"] []} {[net.cgrand/parsley "0.9.1"] [{[net.cgrand/regex "1.1.0"] []}]}]} {[ordered/ordered "1.2.0"] []}]} {[clj-time/clj-time "0.6.0"] [{[joda-time/joda-time "2.2"] []}]}]}