简体   繁体   English

在Clojure中引导引导的Leiningen插件开发

[英]Bootstrapped Leiningen plugin development in Clojure

I am attempting to write a Leiningen plugin that is compatible with the latest release and next 2.0 version, but am having troubles running the plugin on itself. 我正在尝试编写与最新版本和下一个2.0版本兼容的Leiningen插件,但是在自身上运行插件时遇到了麻烦。 What I mean by this is that I would like to write the codes and then run lein foo to run the latest version of plugin code on the plugin code itself. 我的意思是,我想编写代码,然后运行lein foo在插件代码本身上运行最新版本的插件代码。 My project.clj file is below: 我的project.clj文件如下:

(defproject foo "0.0.0"
  :description "simple version for experiment"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [fs "1.1.2"]]
  :source-path "src/clj")

In the src/clj/leiningen folder I have a simple foo.clj file that just calls the function in src/clj/bar/foo-test.clj that prints the contents of the project directory. 在src / clj / leiningen文件夹中,我有一个简单的foo.clj文件,该文件仅调用src / clj / bar / foo-test.clj中的函数,该函数会打印项目目录的内容。 However, whenever I run lein foo it says not able to find foo.clj on CLASSPATH. 但是,每当我运行lein foo它说无法在CLASSPATH上找到foo.clj。 If I move all files from src/clj to src and remove :source-path directive then it runs the right thing in foo.clj but then complains about fs.clj not found on CLASSPATH. 如果我将所有文件从src / clj移到src并删除:source-path指令,那么它将在foo.clj中运行正确的东西,但是会抱怨在CLASSPATH上找不到fs.clj。 I would have hoped this would be easier without the need for adding the foo dependency to project.clj and lein install,deps,foo between changes, but that is currently only way I make it work. 我本来希望这样会更容易,而无需在更改之间将foo依赖项添加到project.clj和lein install,deps,foo ,但这是目前我唯一使之起作用的方式。

Thank you for help! 谢谢你的帮助!

According to: https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md , :source-path is now :source-paths in Leiningen 2.0, and should contain a vector instead of a direct string. 根据: https : //github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md ,在Leiningen 2.0中, :source-path现在是:source-paths ,并且应包含向量而不是直接字符串。

Another potential error is that you don't have :eval-in-leiningen true in the project file. 另一个潜在的错误是您在项目文件中没有:eval-in-leiningen true I believe that is necessary to inherit the CLASSPATH of leiningen itself. 我认为这是继承leiningen本身的CLASSPATH所必需的。 I'm not certain if that is triggering any problems with finding fs.clj though. 我不确定这是否会在找到fs.clj引发任何问题。

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

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