clojure 和 leiningen - 使用 git 存储库作为依赖项 [英] clojure and leiningen - using a git repository as dependency

查看:20
本文介绍了clojure 和 leiningen - 使用 git 存储库作为依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以让 leiningen 直接从 git 存储库(在 github 上)中提取项目作为依赖项?

Is it possible to have leiningen pull a project directly from a git repository (on github) as a dependency?

将 Bundler 与 Ruby 结合使用,可以将 gem 映射到 git 存储库,从而实现相关项目的快速开发和集成.

Using Bundler with Ruby, it is possible to map a gem to a git repo, allowing for rapid development and integration of dependent projects.

更新

基于接受的答案,现在有一个 leiningen 插件来管理 git-deps:https://github.com/tobyhede/lein-git-deps

Based on the accepted answer, there is now a leiningen plugin for managing git-deps: https://github.com/tobyhede/lein-git-deps

推荐答案

2017 答案:使用 lein-voom

您可以使用lein-voom 从 GitHub 或其他 Git 存储库中拉取和构建项目依赖项.它的工作原理是让您使用 voom 特定的元数据注释您的依赖向量对条目.这是自述文件中的一个示例:

Answer for 2017: Use lein-voom

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"]

voom 提供的主要用例是允许在单独的 Git 存储库中维护多个 Clojure 项目的团队轻松地从另一个项目依赖一个或多个项目的当前版本,而无需不断部署开发快照版本.

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.

我更喜欢 lein-voom 而不是 lein-git-deps(在 2012 年之前接受的答案中推荐的插件),原因如下:

I prefer lein-voom over lein-git-deps (the plugin recommended in the previously-accepted answer from 2012) for a few reasons:

  1. 规范是通过元数据给出的,这使得这个插件更加灵活和易于扩展.它已经有一个选项来指定存储库的特定分支/标签.您可以将其他键/值对添加到地图中以进行额外的细粒度控制,而无需做太多工作.

  1. 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.

您可以简单地从您的依赖项中删除元数据以获得稳定版本;即,一旦您的依赖项从 GitHub 转移到 Clojars,就无需移动条目/重构您的 project.clj.

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.

在撰写本文时(2017 年 11 月),lein-voom 已在过去几个月更新,而 lein-git-deps停滞了4年.

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.

这篇关于clojure 和 leiningen - 使用 git 存储库作为依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆