Java 和 Clojure 与 Leiningen

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5432163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 11:06:09  来源:igfitidea点击:

Java and Clojure with Leiningen

javaclojureintegrationleiningenclojure-java-interop

提问by Toby Hede

Is it possible to easily manage and compile native Java classes alongside Clojure in a project using leiningen?

是否可以使用 leiningen 在项目中与 Clojure 一起轻松管理和编译本机 Java 类?

I am working at a pretty low level (with netty nio) and thinking that some of the plumbing classes would actually be easier to handle as raw java both in terms of constructing the code as well as performance.

我在一个相当低的级别(使用 netty nio)工作,并认为在构建代码和性能方面,一些管道类实际上更容易作为原始 Java 处理。

回答by Tom

As of Leiningen 2.x, :java-source-pathhas been replaced with :java-source-paths, whose value is now specified as a vector rather than a string.

从 Leiningen 2.x 开始,:java-source-path已替换为:java-source-paths,其值现在指定为向量而不是字符串。

A good place to find a full (up-to-date) documentation of Leiningen features is to peruse the sample project file. In this case, you will see:

查找 Leiningen 功能的完整(最新)文档的一个好地方是仔细阅读示例项目文件。在这种情况下,您将看到:

:java-source-paths ["src/main/java"]

:java-source-paths ["src/main/java"]

回答by Alex Ott

In Leiningen tutorialthere is following statement

莱宁根教程中有以下声明

For projects that include some Java code, you can set the :java-source-path key in project.clj to a directory containing Java files. Then the javac compiler will run before your Clojure code is AOT-compiled, or you can run it manually with the javac task.

对于包含一些 Java 代码的项目,您可以将 project.clj 中的 :java-source-path 键设置为包含 Java 文件的目录。然后 javac 编译器将在您的 Clojure 代码被 AOT 编译之前运行,或者您可以使用 javac 任务手动运行它。

so it should work out of box if :java-source-pathsoption is set

所以如果:java-source-paths设置了选项,它应该是开箱即用的

回答by zcaudate

Use Vinyasa- I wrote it especially to deal with this problem

使用Vinyasa- 我专门写它来解决这个问题

Here is a blog post Dynamic reloading of java code in emacs/nrepl

这是一篇博客文章在 emacs/nrepl 中动态重新加载 java 代码