Reputation: 37133
Is it possible to have leiningen pull a project directly from a git repository (on github) as a dependency?
Using Bundler with Ruby, it is possible to map a gem to a git repo, allowing for rapid development and integration of dependent projects.
Update
Based on the accepted answer, there is now a leiningen plugin for managing git-deps: https://github.com/tobyhede/lein-git-deps
Upvotes: 40
Views: 8195
Reputation: 1168
I just moved my deps out of Leiningen and into a deps.edn
file using lein-tools-deps. You can still use Leiningen as your build tool and use the plugins. But you can pull git dependencies (and all your other dependencies) using deps.edn
.
Your project.clj
looks something like this:
(defproject example-project "0.1.0-SNAPSHOT"
:source-paths [] ;; provided by lein-tools-deps
:resource-paths [] ;; provided by lein-tools-deps
:min-lein-version "2.0.0"
:main example.core
:aot [example]
:jar-name "example.jar"
:plugins [[lein-tools-deps "0.4.5"]]
:middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn]
:lein-tools-deps/config {:config-files [:install :project]})
and then your deps.edn
is also on the project root and looks something like this:
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/data.json {:mvn/version "1.1.0"}
github/repo {:git/url "https://github.com/github/repo.git"
:sha "e5f5c9e6839191f1e37ddfa51cf442b2d5403ff3"}}}
Upvotes: 2
Reputation: 33019
You can use lein-voom to pull and build project dependencies from GitHub or other Git repositories. It works by letting you annotate your dependence vector-pair entries with voom-specific meta data. Here's an example from the README:
^{:voom {:repo "https://github.com/ring-clojure/ring" :branch "1.3"}}
[ring/ring-core "1.3.0-RC1-20140519_142204-gaf0379b"]
The main use case given for voom is allowing teams that maintain multiple Clojure projects in separate Git repositories to easily depend on the current version of one or more of the projects from another without having to constantly deploy development snapshot releases.
I prefer lein-voom over lein-git-deps (the plugin recommended in the previously-accepted answer from 2012) for a few reasons:
The fact that the specification is given through meta-data makes this plugin more flexible and easily extensible. It already has an option for specifying a specific branch/tag of the repository. You could add other key/value pairs to the map for additional fine-grained control without too much work.
You can simply delete the meta-data from your dependence entry for stable releases; i.e., there's no need to move entries around / refactor your project.clj
once your dependence moves from GitHub into Clojars.
At the time of writing (November 2017), lein-voom has been updated in the past couple of months, whereas lein-git-deps has been stagnant for 4 years.
Upvotes: 5
Reputation: 84331
Leiningen won't do the pulling for you (edit: not out of the box, anyway; following the lead from Sunng's answer leads one to discover that a plugin has been written for this -- see also my comment on that answer; checkout deps remain a good, built-in solution), but you can have checkouts of other projects put on the classpath. This functionality is described in the FAQ section of the README; here's the relevant Q&A:
Q: I want to hack two projects in parallel, but it's annoying to switch between them.
A: If you create a directory calledcheckouts
in your project root and symlink some other project roots into it, Leiningen will allow you to hack on them in parallel. That means changes in the dependency will be visible in the main project without having to go through the whole install/switch-projects/deps/restart-repl cycle, and the copy incheckouts
will take precedence over the dependency declared in project.clj. Note that this is not a replacement for listing the project in:dependencies
; it simply supplements that for convenience.
Upvotes: 10
Reputation: 2191
I just found this in clojurescriptone's project.clj
I think it maybe helpful to you:
:git-dependencies [["https://github.com/clojure/clojurescript.git"
"886d8dc81812962d30a741d6d05ce9d90975160f"]
["https://github.com/levand/domina.git"
"8933b2d12c44832c9bfaecf457a1bc5db251a774"]]
The file is here.
Upvotes: 23