The lein-get
plugin aims to obtain dependencies from sources other
than Maven repositories.
Put [fhofherr/lein-get "0.1.0-SNAPSHOT"]
into the :plugins
vector of
your project.clj
. To execute the plugin issue the following command:
$ lein get
lein-get
inspects your project's dependency vectors to determine
whether it has to perform an action. lein-get
performs its actions
when the lein get
command is called.
The most basic functionality of lein-get
is to link to checkout
dependencies on one of the local file systems. If it encounters
a dependency vector like the following
[some-dependency "0.10.15" :get "../relative/path/on/file/system"]
it resolves the relative path after the :get
keyword. lein-get
uses
the project's root directory, i.e. the directory containing the
project.clj
file as basis for the resolution of the relative path. It
then executes the following actions:
- Check if the resolved path exists and is a directory
- Check if the resolved path contains a
project.clj
file - Create a symbolic link to the resolved path in the current project's
checkouts
directory. The last component of the resolved path --system
in the above example -- is used as the name of the symbolic link. - Change into the symlinked directory and execute
lein install
in a new process.
If the path after :get
is an absolute path lein-get
skips the path
resolution and performs the listed actions.
The dependency vector
[some-dependency "0.10.15" :get {:type :leiningen-checkout
:path {:scm :file
:uri "../relative/path/on/file/system"}}]
is the verbose form of the dependency vector shown above. The relative
path referenced by :uri
is resolved to a full file://
URI using the
project's root directory.
In addition to obtaining checkout dependencies from the local file system checkout dependencies can be directly downloaded from git. To achieve this specify the following dependency vector:
[some-dependency "0.10.15" :get {:type :leiningen-checkout
:path {:scm :git
:uri "https://url/of/git/repo"}}]
This makes lein-get
perform the following actions:
- Clone the specified git repository into a sub-directory of the
current project's
referenced-projects
directory. Just as with a normalgit clone
the last part of the repository's url will be used as the target directory of the clone. If the repository has already been cloned by a previous invocation oflein get
agit pull
is performed instead. - If the cloned or updated repository has a tag whose name ends with the version specified in the dependency vector this tag is checked out. Otherwise the repository's default branch is used.
- Perform the same steps as in Link to checkout
dependencies but use
referenced-projects/repo
as the directory of the referenced project.
If a different branch or tag is desired it can be specified by adding
:branch
or :tag
to the map specifying the path. The :branch
and
:tag
keywords are treated in exactly the same way by lein-get
, thus
a tag could be referenced by using :branch
and vice versa. Adding
either :branch
or :tag
makes lein-get
checkout the referenced
branch or tag before executing lein install
.
Example:
[some-dependency "0.10.15" :get {:type :leiningen-checkout
:path {:scm :git
:uri "https://url/of/git/repo"
:tag "v0.1.0"}}]
Copyright © 2018 Ferdinand Hofherr
Distributed under the MIT License.