简体   繁体   English

如何使用leiningen的maven插件

[英]How to use a maven plugin from leiningen

The specific plugin I want to be able to use is the jruby-maven-plugin so I can easily use compass in a clojure project. 我希望能够使用的特定插件是jruby-maven-plugin,因此我可以在clojure项目中轻松使用指南针。

If it's not possible to use maven plugins, what would be the best strategy to use a ruby gem in a clojure project? 如果不可能使用maven插件,那么在clojure项目中使用ruby gem的最佳策略是什么?

The following two projects provide ruby gem support. 以下两个项目提供ruby gem支持。 lein-ruby clogems lein-ruby clogems

clogems project does not have anything in the way of documentation, so you are probably on your own with that. clogems项目没有任何文档的方式,所以你可能是你自己的。

lein-ruby provides some documentation on it's github page. lein-ruby在github页面上提供了一些文档。 From the github page for lein-ruby. 来自lein-ruby的github页面。

Usage 用法

Tasks 任务

This plugin adds one task to Leiningen: 这个插件为Leiningen增加了一项任务:

  • lein ruby CMD [ARGS...] - runs a Ruby command lein ruby CMD [ARGS...] - 运行Ruby命令

You are responsible for adding the desired version of jruby-complete to your project's dependencies. 您负责将所需版本的jruby-complete添加到项目的依赖项中。

Hooks

The plugin also includes a set of hooks (in the leiningen.ruby.bundler namespace) which accomplish three things: 该插件还包含一组钩子(在leiningen.ruby.bundler命名空间中),它完成三件事:

  • augment lein deps to install bundler and any gems specified in your project's Gemfile into vendor/gems 增加lein deps将bundler和项目Gemfile中指定的任何gem安装到vendor/gems

  • add vendor/gems to your project's classpath vendor/gems添加到项目的类路径中

  • package the gems in vendor/gems as part of your project's jar 将gem vendor/gems作为项目jar的一部分打包

Options 选项

lein-ruby also introduces two options which can be set in your project.clj: lein-ruby还介绍了两个可以在project.clj中设置的选项:

  • :ruby-version - the Ruby version to use for lein ruby : "1.8" or "1.9" (default) :ruby-version - 用于lein ruby的Ruby版本:“1.8”或“1.9”(默认)

  • :ruby-gem-dir - the directory to use for gems, relative to the project root (defaults to vendor/gems ) :ruby-gem-dir - 用于gems的目录,相对于项目根目录(默认为vendor/gems

It seems it is possible to use Mavern plugins and dependancies. 似乎可以使用Mavern插件和依赖。 Looking at Leiningen's GitHub , I found the following pieces of information that seem relevant: 看看Leiningen的GitHub ,我发现以下几条相关的信息:

:dependencies [[org.clojure/clojure "1.8.0"]
               [clj-http "2.0.0"]]

Leiningen will automatically download the clj-http jar and make sure it is on your classpath. Leiningen将自动下载clj-http jar并确保它在你的类路径上。

... ...

Leiningen reuses existing JVM repository infrastructure. Leiningen重用现有的JVM存储库基础结构。 There are several popular open source repositories. 有几个流行的开源存储库。 Leiningen by default will use two of them: clojars.org and Maven Central. Leiningen默认使用其中两个:clojars.org和Maven Central。

You can add third-party repositories by setting the :repositories key in project.clj. 您可以通过在project.clj中设置:repositories键来添加第三方存储库。 See the sample.project.clj for examples on how to do so. 有关如何执行此操作的示例,请参阅sample.project.clj

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

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