简体   繁体   English

如何安装leiningen插件?

[英]How to install a leiningen plugin?

How do I install a leiningen plugin? 如何安装leiningen插件?

For example, leiningen-run? 例如,leiningen-run?

I see this thing called "clojars.org", and how to "push" to it, but I don't see anything about "pulling" from it. 我看到这个名为“clojars.org”的东西,以及如何“推”到它,但我没有看到任何关于“拉”的东西。

If a plugin's available at Clojars, like lein run is, just add it to your project's :dev-dependencies in project.clj, then say lein deps in your project's directory to have Leiningen pull in all dependencies . 如果在Clojars上有一个插件,比如lein run,只需将它添加到项目的:dev-dependencies project.clj中的:dev-dependencies ,然后在项目目录中说lein deps让Leiningen引入所有依赖项 An annotated excerpt from lein run's docs: 来自lein run的文档的注释摘录:

(defproject island-wari "0.1"
  :description "Web application for playing the Island Wari game."
  :main wari
  :dependencies     [[org.clojure/clojure "1.1.0-master-SNAPSHOT"]
                     [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]
                     [org.clojars.liebke/compojure "0.3.1-master"]]
  :dev-dependencies [[org.clojure/swank-clojure "1.0"]
                     [leiningen-run "0.2"]]) ; <--- this bit makes it possible
                                             ;      to use lein run

Having done the above, you should be able to say lein run in your project's directory to run your app. 完成上述操作后,您应该可以说lein run在项目目录中运行以运行您的应用程序。

Update: Should you want to write your own plugins for Leiningen, check out this tutorial on nakkaya.com . 更新:如果您想为Leiningen编写自己的插件,请查看nakkaya.com上的本教程 Even if you're not planning on writing lein plugins, still check out that blog, it absolutely positively rocks. 即使你不打算写lein插件,仍然看看那个博客,它绝对是积极的。

Depending on a plugin 取决于插件

With Leiningen 2.0 and greater you specify which plugins you want as values to :plugins in your project map. 使用Leiningen 2.0及更高版本,您可以指定要作为值的:plugins项目图中的:plugins See the sample project.clj file. 请参阅示例project.clj文件。 Note that "sample" is a bit of a misnomer, it's a reference for all possible (built-in) keys and documentation of their defaults. 请注意,“示例”有点用词不当,它是所有可能(内置)键及其默认值文档的参考。

lein-run 雷音运行

The lein-run functionality is now part of core leiningen and doesn't need to be specified as a plugin lein-run功能现在是leiningen核心的一部分,不需要指定为插件

clojars.org clojars.org

Clojars is a repository of clojure libraries quite similar to maven central (or to some lesser extent, rubygems). Clojars是一个clojure库的存储库,非常类似于maven central(或者在某种程度上,类似于rubygems)。 You don't pull from it explicitly. 你没有明确地从中拉出来。 Instead, Leiningen is configured to search through a standard set of repos for your :dependencies Eg maven central and clojars. 相反,Leiningen配置为搜索标准的repos集合:dependencies例如maven central和clojars。 Maven uniquely identifies its dependencies (artifacts in maven parlance) by a triple (group-name, artifact-name, version) . Maven通过三元(group-name, artifact-name, version)唯一地标识其依赖关系(maven用语中的(group-name, artifact-name, version) Leiningen leverages the exact same mechanism with the exception that the group name does not have the restriction of being a reverse URI the way it must be with maven central. Leiningen利用完全相同的机制,除了组名不具有与maven central一样的反向URI的限制。 In practice you'll tend to see many libraries published in clojars where the name nicely matches the clojure namespace and github project name without the annoying com.mydomain.awesomelib 在实践中,你会看到很多库在clojars中发布,其中名称很好地匹配clojure命名空间和github项目名称而没有烦人的com.mydomain.awesomelib

You can set your own repos to be searched (or tweak various options) via :repositories in you project.clj . 您可以通过以下项目设置自己的repos(或调整各种选项) :repositories project.clj中的 :repositories You can similarly set :mirrors if you have an in-house mirror of a maven repo. 如果你有一个maven repo的内部镜像,你可以类似地设置:mirrors

"Installing" an unpublished plugin “安装”未发布的插件

Finally, though I don't think that's directly what you were asking but it's still interesting, If you're developing a plugin or what to depend on a plugin that hasn't been officially published, you can set :plugin-repositories 最后,虽然我不认为这直接是你问的问题,但它仍然很有趣,如果你正在开发一个插件或者什么依赖于尚未正式发布的:plugin-repositories ,你可以设置:plugin-repositories

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM