是否有可能让leiningen直接从git存储库(在github上)作为依赖项拉出项目?
将Bundler与Ruby结合使用,可以将gem映射到git repo,从而可以快速开发和集成依赖项目。
更新
根据接受的答案,现在有一个用于管理git-deps的leiningen插件: https://github.com/tobyhede/lein-git-deps
答案 0 :(得分:22)
我刚在clojurescriptone的project.clj
中找到了这个我认为这对你有帮助:
:git-dependencies [["https://github.com/clojure/clojurescript.git"
"886d8dc81812962d30a741d6d05ce9d90975160f"]
["https://github.com/levand/domina.git"
"8933b2d12c44832c9bfaecf457a1bc5db251a774"]]
该文件为here。
答案 1 :(得分:10)
Leiningen不会为你拉动(编辑:不是开箱即用的;无论如何;在Sunng的回答中引导人们发现已经为此写了一个插件 - 另见我的评论在那个答案; checkout deps仍然是一个很好的,内置的解决方案),但你可以检查其他项目放在类路径上。此功能在README的FAQ部分中描述;这是相关的Q& A:
问:我想要并行攻击两个项目,但这很烦人 在它们之间切换。
A:如果您在中创建名为checkouts
的目录 你的项目根和符号链接一些其他项目根源, Leiningen将允许您并行攻击它们。这意味着 在没有的情况下,主项目中将显示依赖项中的更改 不得不经历整体 install / switch-projects / deps / restart-repl cycle,以及副本checkouts
将优先于声明的依赖项 project.clj。请注意,这不是列出的替代品:dependencies
中的项目;它只是为了方便而补充。
答案 2 :(得分:3)
您可以使用lein-voom从GitHub或其他Git存储库中提取和构建项目依赖项。它的工作原理是让您使用 voom 特定的元数据注释您的依赖向量对条目。以下是自述文件中的一个示例:
TlsException: The authentication or decryption has failed.
Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) (at <eb1224ae7b184cd09343d47f8a05481b>:0)
Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) (at <eb1224ae7b184cd09343d47f8a05481b>:0)
Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) (at <eb1224ae7b184cd09343d47f8a05481b>:0)
Rethrow as IOException: The authentication or decryption has failed.
Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) (at <eb1224ae7b184cd09343d47f8a05481b>:0)
Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) (at <eb1224ae7b184cd09343d47f8a05481b>:0)
Rethrow as IOException: The authentication or decryption has failed.
Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) (at <eb1224ae7b184cd09343d47f8a05481b>:0)
Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) (at <344dc4d3f1ad41809df78607b6121a41>:0)
Mono.Net.Security.Private.LegacySslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) (at <344dc4d3f1ad41809df78607b6121a41>:0)
Mono.Net.Security.MonoTlsStream.CreateStream (System.Byte[] buffer) (at <344dc4d3f1ad41809df78607b6121a41>:0)
System.Net.WebConnection.CreateStream (System.Net.HttpWebRequest request) (at <344dc4d3f1ad41809df78607b6121a41>:0)
Rethrow as WebException: Error: SecureChannelFailure (The authentication or decryption has failed.)
System.Net.WebClient.DownloadDataInternal (System.Uri address, System.Net.WebRequest& request) (at <344dc4d3f1ad41809df78607b6121a41>:0)
System.Net.WebClient.DownloadString (System.Uri address) (at <344dc4d3f1ad41809df78607b6121a41>:0)
System.Net.WebClient.DownloadString (System.String address) (at <344dc4d3f1ad41809df78607b6121a41>:0)
voom 的主要用例是允许在单独的Git存储库中维护多个Clojure项目的团队轻松地依赖于另一个项目的一个或多个项目的当前版本,而无需经常部署开发快照发布。
我更喜欢 lein-voom 而不是 lein-git-deps (2012年之前接受的答案推荐的插件),原因如下:
规范是通过元数据提供的,这使得这个插件更加灵活,易于扩展。它已经有一个选项来指定存储库的特定分支/标记。您可以在地图中添加其他键/值对,以进行额外的细粒度控制,而无需太多工作。
您可以简单地从您的依赖条目中删除稳定版本的元数据;也就是说,一旦你的依赖从GitHub转移到Clojars,就没有必要移动条目/重构你的^{:voom {:repo "https://github.com/ring-clojure/ring" :branch "1.3"}}
[ring/ring-core "1.3.0-RC1-20140519_142204-gaf0379b"]
。
在撰写本文时(2017年11月), lein-voom 在过去几个月内已更新,而 lein-git-deps 已更新已经停滞了4年。
答案 3 :(得分:0)
我刚刚使用 lein-tools-deps 将我的 deps 从 Leiningen 移到了 deps.edn
文件中。您仍然可以使用 Leiningen 作为构建工具并使用插件。但是您可以使用 deps.edn
拉取 git 依赖项(以及所有其他依赖项)。
您的 project.clj
看起来像这样:
(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]})
然后您的 deps.edn
也在项目根目录中,如下所示:
{: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"}}}