API for clojure.tools.deps
-
Full namespace name:
clojure.tools.deps
Overview
API namespace for tools.deps. New dep types are defined via the multimethods
in c.t.deps.extensions. This namespace auto-loads the built-in extensions for
:mvn, :git, :local, etc. Most functions for reading, validating, and manipulating
deps.edn data have been deprecated and moved to clojure.tools.deps.edn library.
Public Variables and Functions
function
Usage: (root-deps)
DEPRECATED: Use clojure.tools.deps.edn/root-deps
Deprecated since tools.deps version 1.0
Source
function
Usage: (slurp-deps dep-file)
DEPRECATED: use clojure.tools.deps.edn/read-deps
Deprecated since tools.deps version 1.0
Source
function
Usage: (user-deps-path)
DEPRECATED: Use clojure.tools.deps.edn/user-deps-path
Deprecated since tools.deps version 1.0
Source
Functions for reading, validating, and manipulating deps.edn
files and data structures.
Public Variables and Functions
function
Usage: (canonicalize deps-edn & opts)
Canonicalize a deps.edn map (convert simple lib symbols to qualified lib symbols).
Returns the deps-edn map.
Opts:
:path String path to file being read
function
Usage: (combine-aliases edn-map alias-kws)
Find, read, and combine alias maps identified by alias keywords from
a deps edn map into a single args map.
function
Usage: (create-edn-maps)
(create-edn-maps {:keys [root user project extra], :as params, :or {root :standard, user :standard, project :standard}})
Takes optional map of location sources, keys = :root :user :project :extra
where each key may be:
:standard (default) - to get the default source
string - for file path to source, relative to current dir context
nil - to omit
map - a literal map to use
Returns a set of deps edn maps with the same keys :root :user :project :extra.
Keys may be missing if source was nil or file was missing.
function
Usage: (merge-alias-maps & ms)
Like merge-with, but using custom per-alias-key merge function
function
Usage: (merge-edns deps-edn-maps)
Merge multiple deps edn maps from left to right into a single deps edn map.
function
Usage: (project-deps)
Calculate the project deps.edn location, read and return the deps.edn data.
You may use clojure.tools.deps.util.dir/with-dir to read from a custom project
dir, either absolute or relative to the current dir context.
function
Usage: (project-deps-path)
Calculate the project deps.edn location. This
is the deps.edn in the current directory, as defined by
clojure.tools.deps.util.dir/*the-dir* - use with-dir
to push a new local directory context around a call to
project-deps-path.
function
Usage: (read-deps f & opts)
Corece f to a file with jio/file, then read, validate, and canonicalize
the deps.edn. This is the primary entry point for reading.
Use read-edn, validate, or canonicalize for individual steps.
Opts: none for now
function
Usage: (read-edn r & opts)
Read edn from Reader r, which should contain exactly one edn value.
If source exists but is blank, nil is returned.
Throws if source is unreadable or contains multiple values.
Opts:
:path String path to file being read, for error reporting
function
Usage: (root-deps)
Read the root deps.edn resource from the classpath at the path
clojure/tools/deps/deps.edn
function
Usage: (user-deps)
Calculate the user deps.edn per user-deps-path, read and
return the deps.edn data
function
Usage: (user-deps-path)
Use the same logic as clj to calculate the location of the user deps.edn.
Note that it's possible no file may exist at this location.
function
Usage: (validate deps-edn & opts)
Validate a deps-edn map according to the specs, throw if invalid.
Returns the deps-edn map.
Opts:
:path String path to file being read
Public Variables and Functions
function
Usage: (explain-deps deps-map)
If a spec is invalid, return a message explaining why, suitable
for an error message
function
Usage: (valid-deps? deps-map)
Determine whether the deps map is valid according to the specs
Specs
spec
(map-of ::alias any?)
spec
(keys :opt-un [::classpath-overrides ::extra-paths])
spec
(map-of ::lib ::path)
spec
(nilable (or :mvn :mvn/coord :local :local/coord :git :git/coord))
spec
(map-of ::lib ::coord)
spec
(map-of ::lib ::coord)
spec
(nilable
(keys
:opt-un [::paths ::deps ::aliases]
:opt [:mvn/repos :mvn/local-repo :tools/usage :deps/prep-lib]))
spec
(map-of ::lib ::coord)
spec
(coll-of ::path-ref :into [] :kind vector?)
spec
(map-of ::lib ::resolved-coord)
spec
(map-of simple-symbol? simple-symbol?)
spec
(map-of ::lib ::coord)
spec
(or :path ::path :alias ::alias)
spec
(coll-of ::path-ref :into [] :kind vector?)
spec
(map-of ::lib ::coord)
spec
(coll-of ::path-ref :into [] :kind vector?)
spec
(nilable (keys :opt-un [::url :mvn/releases :mvn/snapshots]))
spec
(keys :opt-un [::extra-deps ::override-deps ::default-deps])
spec
(merge ::coord (keys :opt-un [:aliased/paths ::dependents]))
spec
(keys :opt-un [::replace-deps ::replace-paths ::deps ::paths])
API for managing CLI tools. This code may eventually move out of tools.deps
and into the CLI code base as it is specific to the CLI.
Public Variables and Functions
function
Usage: (install-tool lib coord as)
Procure the lib+coord, install the tool to the user tools dir (with lib, coord)
Source
function
Usage: (list-tools)
Return seq of available tool names
Source
function
Usage: (remove-tool tool)
Removes tool installation, if it exists. Returns true if it exists and was deleted.
Source
function
Usage: (resolve-tool tool)
Resolve a tool by name, look up and return:
{:lib lib
:coord coord}
Or nil if unknown.
Source
function
Usage: (usage tool)
Resolve a tool and return it's usage data, which may be nil.
Throws ex-info if tool is unknown.
Source
API for managing deps trace structures and extracting tree renderings from
traces. Note that deps are actually a graph and trees usually show the library
more than once, expanding only once.
Public Variables and Functions
function
Usage: (trace->tree trace)
Convert a deps trace data structure into a deps tree.
A deps tree has the structure of the full dependency expansion.
Each node of the tree is a map from lib to coord-info with at least these keys:
:lib - library symbol
:coord - the coord map that was used (may not be the original coord if replaced
due to default-deps or override-deps)
:include - boolean of whether this node is included in the returned deps
:reason - why the node was or was not included
:children - vector of child nodes
Source
An abstraction for managing a 'current directory' stack.
The dynamic var `*the-dir*` holds the current directory.
Use `with-dir` to push a new absolute (or more usefully)
relative directory onto the stack, which will pop when the
scope exits. Use `canonical` to get the canonical File
of a path in terms of the current directory context.
Public Variables and Functions
dynamic var
Thread-local directory context for resolving relative directories.
Defaults to current directory. Should always hold an absolute directory
java.io.File, never null.
function
Usage: (canonicalize f)
Make canonical File in terms of the current directory context.
f may be either absolute or relative.
function
Usage: (sub-path? path)
True if the path is a sub-path of the current directory context.
path may be either absolute or relative. Will return true if path
has a parent that is the current directory context, false otherwise.
Handles relative paths, .., ., etc. The sub-path does not need to
exist on disk (but the current directory context must).
macro
Usage: (with-dir dir & body)
Push directory into current directory context for execution of body.