简体   繁体   English

如何在leiningen项目中打包资源

[英]how to package resources in a leiningen project

in the sample project, 在示例项目中,

https://github.com/technomancy/leiningen/blob/master/sample.project.clj https://github.com/technomancy/leiningen/blob/master/sample.project.clj

on line 217 , there is a directive for including non-code files : line 217 ,有一个包含非代码文件的指令:

:resource-paths ["src/main/resource"] ; non-code files included in classpath/jar

I have a resources folder in my project and this line in my project.clj 我的项目中有一个resources文件夹,而project.clj中的这一行

:resource-paths ["resources"] ; non-code files included in classpath/jar

however, when I run lein jar to generate the .jar file, it does not package up the resources folder. 但是,当我运行lein jar生成.jar文件时,它不会打包resources文件夹。

Is there something that I am missing? 有什么我想念的吗?

Actually, it did get packaged. 实际上,它确实被包装了。 I just was not looking in the right spot: 我只是没有找到正确的位置:

from: Resources in Clojure applications 来自: Clojure应用程序中的资源

'Leiningen borrows the convention for resources from maven, with slightly different folder layouts. 莱宁根从Maven借用了资源约定,文件夹布局略有不同。 The rule states that the resources folder must be used as a compile time classpath root, meaning that leiningen is right in putting all the files inside resources folder in the root location inside the jar.' 该规则指出资源文件夹必须用作编译时类路径的根,这意味着leiningen正确地将资源文件夹中的所有文件放在jar的根位置。

I thought that a resources directory would get created with the jar itself but lein jar copied all the files in the resources directory to the root of the jar. 我以为将用jar本身创建一个资源目录,但是lein jar将资源目录中的所有文件复制到jar的根目录。

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

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