ancient-clj is a library for accessing versioning metadata in Maven repositories. It is the base for the Leiningen plugin lein-ancient.
Version comparison is done using version-clj.
(require '[ancient-clj.core :as ancient])
The base of all ancient-clj operations is a map associating an ID with a repository specification, given as one of the following:
http://...
, https://...
, file://...
, s3p://...
),:uri
and repository-specific settings (:username
, :passphrase
, ...),(:uri
and :url
, as well as :passphrase
and :password
are interchangeable.)
Example:
{"central" "http://repo1.maven.org/maven2"
"clojars" "https://clojars.org/repo"
"http-auth" {:uri "https://my.repo.server/releases"
:username "HTTP_BASIC_AUTH_USER"
:passphrase "HTTP_BASIC_AUTH_PASSWORD"}
"s3" {:uri "s3p://maven/bucket"
:username "AWS_ACCESS_KEY"
:passphrase "AWS_SECRET_KEY"}}
The default repositories are stored in ancient-clj.core/default-repositories
.
Artifacts can be given as everything implementing ancient-clj.artifact/Artifact
:
[ancient-clj "0.2.0"]
, [ancient-clj]
, ...)ancient-clj
, :ancient-clj/ancient-clj
, "ancient-clj"
):group
, :id
and :version-string
.All ancient-clj functions take one of those as first parameter, as well as an optional map of options as second one:
:snapshots?
: whether or not to consider SNAPSHOT versions in the results (default: true),:qualified?
: whether or not to consider alpha/beta/RC/... versions in the results
(default: true),:sort
: how to sort the results (:desc
(default), :asc
, :none
),:repositories
: see above (default: Maven Central + Clojars).To analyze an artifact use ancient-clj.core/read-artifact
:
(ancient/read-artifact '[com.taoensso/timbre "3.3.1"])
;; => {:form [com.taoensso/timbre "3.3.1"],
;; :symbol com.taoensso/timbre,
;; :version-string "3.3.1",
;; :version [(3 3 1)],
;; :id "timbre",
;; :group "com.taoensso"}
The base of all operations is versions-per-repository!
which produces a map of either
a seq of version maps or a Throwable associated with each repository ID:
(ancient/versions-per-repository! 'ancient-clj)
;; => {"clojars" ({:version [(0 1 10)], :version-string "0.1.10"} ...)
;; "central" (...)}
(ancient/versions-per-repository!
'ancient-clj
{:repositories {"invalid" "http://nosuchpage.maven.org"}})
;; => {"invalid" #<UnknownHostException java.net.UnknownHostException: ...>}
As you can see, versions are given as a map of :version-string
and :version
(a version-clj
version value).
Flat seqs of version maps/strings can be obtained using versions!
and version-strings!
, the
latest ones are returned by latest-version!
and latest-version-string!
.
artifact-outdated?
and artifact-outdated-string?
only return a version value if it is
of a more recent version than the input artifact.
Since version 1.0.0, ancient-clj depends on pomegranate (and thus Aether)
and can benefit from any wagons that are registered there. Please use
cemerick.pomegranate.aether/register-wagon-factory!
to utilise this feature.
MIT License
Copyright (c) 2013-2021 Yannick Scherer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close