问题标签 [leiningen]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
432 浏览

clojure - How do i determine the correct filesystem path

I am working on an application that has to download some external resources and make them accessible through a public/static directory in Ring.

But.. I have a problem saving the resources into a static directory in my application, when developing I use the ring-jetty-adapter; the test & production servers are running Tomcat.

I added :web-content "public" to my leiningen project and added the public directory in the root of the project, then I have a download function using http-agent and duck-streams:

If I am booting Jetty from the REPL and use savepath: "public/my.file", the downloaded file is placed correctly in the public directory. But when I deploy it using a .war file to Tomcat, it looks for a public directory in the Tomcat root directory, and not under the application context path.

I tried to add a middleware wrapper to determine the context path and from there build the correct save path, but I cannot find any way to access the HttpServlet or a way to determine if the application is running in the adapter or if it is deployed under a specific context.

Here the wrapper:

both :servlet and :req are nil.

0 投票
2 回答
838 浏览

emacs - 如何从 Emacs 中自动加载 leiningen repl?

我正在使用 Emacs,与 Leiningen 的 swank集成。每次我需要开始使用 .clj 文件时,我都必须:

  1. emacs pack/my-ns.clj从控制台运行。
  2. 键入M-x lein-swank
  3. 编译缓冲区。
  4. 在 Clojure REPL 中更改命名空间,即 type (in-ns 'pack.my-ns)

如何自动化此过程以仅从控制台运行emacs-clj pack/my-ns.clj并让我的环境准备好使用?

0 投票
1 回答
3245 浏览

clojure - 使用 lein uberjar 生成的 Jar 在 NoClassDefFoundError 上失败

我有一个带有这个 project.clj 的简单网络应用程序:

我的主要看起来像这样:

使用 REPL 就可以了。但是,当我生成一个 jarlein uberjar并尝试将其执行为:

它死于此异常:

我究竟做错了什么?如何让它工作?

不确定这是否重要,但我注意到在 jar 中我的文件、clojure 本身和 Java 库被解压缩为 .class 文件,而所有 clojure 库仅作为普通的 .clj 文件存在。

0 投票
2 回答
11603 浏览

clojure - leiningen 的命令行参数

我最近开始使用 clojure,我正在使用 leiningen 创建一个小项目。我在让 leiningen 使用命令行参数时遇到了麻烦。以下是我的src/project/core.clj

和我的project.clj

现在当我运行时lein run arg1 arg2,它给了我这个错误:

但是,如果我做 alein uberjar然后做java -jar project-1.0.0-SNAPSHOT-standalone.jar arg1 arg2,我会得到正确的输出。

每次开发时都必须创建 uberjar 来运行它不是很舒服,有没有更好的方法?

0 投票
2 回答
495 浏览

java - 如何在 Clojure 中扩展受保护的方法

如何在 Clojure 中写这个?

我正在尝试vaadin srvlet用 clojure 编写课程:

http://dev.vaadin.com/wiki/Articles/ClojureScripting

0 投票
1 回答
2308 浏览

clojure - leiningen 默认存储库是什么?

Leiningen (https://github.com/technomancy/leiningen) 查看一些默认存储库以满足您在 project.clj 中指定的依赖项。

我想浏览这些存储库以查看 leiningen 中开箱即用的内容。这些存储库是什么,我在哪里可以找到我特定版本的 leiningen。

0 投票
1 回答
1803 浏览

clojure - 建立需要基于构建平台的不同依赖项的 leiningen 项目的优雅方法是什么?

为了进行一些多平台 GUI 开发,我刚刚从 GTK + Clojure(因为看起来 GTK 的 Java 绑定从未移植到 Windows)切换到 SWT + Clojure。到目前为止,我已经为 Linux 构建了一个 uberjar。

不过,问题是我想为 Windows 构建一个 uberjar,并且我正在尝试找出一种干净的方法来管理 project.clj 文件。

起初,我想我会将类路径设置为指向 SWT 库,然后构建 uberjar。这需要我在运行 jar 之前设置 SWT 库的类路径,但无论如何我可能需要一个启动器脚本。但是,leiningen 在这种情况下似乎忽略了类路径,因为它总是报告

目前,project.clj 对我来说是这样的:

相关行是org.eclipse/swt-gtk-linux-x86行。如果我想为 Windows 制作一个 uberjar,我必须依赖org.eclipse/swt-win32-win32-x86, 另一个用于x86-64, 依此类推。

我当前的解决方案是简单地为每个构建环境创建一个单独的分支,使用不同的project.clj. 这似乎有点像使用半成品来提供一加仑牛奶,但我使用 bazaar 进行版本控制,因此分支和重复集成很容易。也许更好的方法是使用project.linux.clj,project.win32.clj等,但我看不出有任何方法可以告诉 leiningen 使用哪个项目描述符。

还有什么其他(最好更优雅)的方式来设置这样的环境?

0 投票
2 回答
1380 浏览

unit-testing - Unicode Clojure 单元测试输出

在对一些将 ascii 序列转换为 unicode 字符的代码进行单元测试时,我发现 Clojure 测试的输出存在问题。

我已经测试过我的终端可以输出 unicode 字符(通过 cat-ing 测试文件)并且工作正常,所以问题似乎与 leiningen、Clojure 或 clojure.test 有关。

这是一个示例测试(使用 unicode 的希腊语部分 - 我也将使用扩展的希腊语,但我认为同样的问题也会适用):

由于输入中缺少空格,它意味着失败。的输出lein test如下:

我在这里做错了什么?这是终端仿真问题还是与 clojure 相关的问题?我在使用 Slime/swank/emacs 的 REPL 中运行代码时遇到了同样的问题。emacs 中的 REPL 只输出 unicode 输出的问号(尽管 emacs 非常有能力理解 unicode)。

我尝试在终端和 iTerm (OS X) 中运行它,结果相同。

0 投票
2 回答
2831 浏览

clojure - Clojure 安装项目并将其放在类路径中

我刚刚安装了criterium,我希望能够从 repl 和其他项目中使用它。如何扩展 java 类路径以便可以从任何地方使用已安装的库?

我很感激能在我将来从事的所有项目中轻松工作的答案。我正在使用 leiningen,我想它会在你运行时执行此操作lein install,但要么我做错了什么,要么这还不够。

0 投票
2 回答
326 浏览

macos - Clojure REPL 在 OS X 上打印 doseq 输出时卡住了,但在 Linux 上却没有

我通过命令在我的 Snow Leopard OS X 机器和我的 Ubuntu linux 机器上运行 Clojure 1.2 lein repl。我正在阅读 enlive 教程https://github.com/swannodette/enlive-tutorial/

当我进入“第三次刮擦”教程并运行以下命令时:

它在 Ubuntu 上按预期工作,但在 OS X 上,它只输出第一个故事,然后只有在我输入一些表达式后才输出其余的故事,无论是数字、a (println "hello world") 还是诸如此类。REPL 在 OS X 上的工作方式似乎有些奇怪——就好像缓冲区没有完全刷新它的输出一样。

我注意到函数doseq中使用了一个宏print-stories。所以如果我这样做:

我在 OSX 上得到这个输出:

这只是第一项。如果我然后输入0(或任何有效的表达式)并按回车,我会得到其余的输出:

我还注意到这种行为并不一致。有时,什么都没有输出,然后我可以通过键入0或其他东西将其刷新并输入。有时,它会正确清除所有输出。

有没有人有任何想法?