eclipse 在 IDE 中使用 clojure 和 leiningen

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2136792/
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-09-19 14:20:57  来源:igfitidea点击:

Using clojure and leiningen with IDEs

eclipsenetbeansclojureintellij-idealeiningen

提问by Arthur Ulfeldt

I'm looking at switching my projects build from Ant to leiningen and wanted to know if there is a Clojure IDE (intellij, eclipse, netbeans) for which the "build" and "debug" buttons will still work?

我正在考虑将我的项目构建从 Ant 切换到 leiningen,想知道是否有一个 Clojure IDE(intellij、eclipse、netbeans)“构建”和“调试”按钮仍然有效?

采纳答案by Arthur Edelstein

I have had some luck with La Clojure and the "Leiningen" plugin for IntelliJ IDEA. After creating a new project on the command line with lein new, I created a new project in IntelliJ. The Run Configuration Script Path needs to be pointed to the core.clj file, and the Module Settings "Dependencies" need to include the lib directory as a "Module Library."

我对 La Clojure 和 IntelliJ IDEA 的“Leiningen”插件有一些运气。在命令行上lein new创建一个新项目后,我在 IntelliJ 中创建了一个新项目。Run Configuration Script Path需要指向core.clj文件,Module Settings“Dependencies”需要包含lib目录作为“Module Library”。

The Leiningen plugin offers the usual lein commands, so you can build your jar directly from the IDE (or from the shell). You can edit your project.clj file from IDEA, and the Run and Debug seem to work as well.

Leiningen 插件提供了常用的 lein 命令,因此您可以直接从 IDE(或从 shell)构建 jar。您可以从 IDEA 编辑您的 project.clj 文件,运行和调试似乎也能正常工作。

BTW, I also found this screencastvery helpful for getting started with La Clojure.

顺便说一句,我还发现这个截屏视频对于开始使用 La Clojure 非常有帮助。

回答by Alistair Collins

I've been using Eclipse and CounterClockwise plugin with Leiningen configured to be accessed via External Tools. As the blog post title says, it's a "Poor Man's Integration", but has worked for the example I've tried.

我一直在使用 Eclipse 和 CounterClockwise 插件,其中 Leiningen 配置为通过External Tools访问。正如博客文章标题所说,这是一个“穷人的整合”,但对我尝试过的例子有效。

回答by Colbert Sesanker

For debugging, syntax highlighting, and running clojure in Eclipse try:

要在 Eclipse 中进行调试、语法高亮显示和运行 clojure,请尝试:

  1. Download counterclockwise for syntax highlighting via external tools using the update site.

  2. Add [lein-eclipse "1.0.0"]to your dependencies in your project.clj file.

  3. Add the plugin manually with command: lein plugin install lein-eclipse "1.0.0". This step is included because just adding the dependency doesn't always work.

  4. Run the command lein eclipsein project folder to generate eclipse .project and .classpath files. This step might take awhile. If it gets stuck, run it again. It should say "created .project and .classpath".

  5. Restart Eclipse.

  6. Go to |File -> Import -> General -> Existing Projects in Workspace| and select the project folder. You should be able to select the clojure project, debug and run it.

  1. 使用更新站点通过外部工具逆时针下载语法高亮。

  2. 添加[lein-eclipse "1.0.0"]到您的 project.clj 文件中的依赖项。

  3. 使用命令手动添加插件: lein plugin install lein-eclipse "1.0.0". 包含此步骤是因为仅添加依赖项并不总是有效。

  4. lein eclipse在项目文件夹中运行命令以生成 eclipse .project 和 .classpath 文件。此步骤可能需要一段时间。如果卡住了,再运行一次。它应该说“创建了 .project 和 .classpath”。

  5. 重新启动 Eclipse。

  6. 转到 |文件 -> 导入 -> 常规 -> 工作区中的现有项目 | 并选择项目文件夹。您应该能够选择 clojure 项目,调试并运行它。

Notes: It doesn't seem to add the dev-dependencies to the project classpath. Also, you need to change your workspace to the folder with the project so it does not make a second copy of the project and uses the actual files.

注意:它似乎没有将开发依赖项添加到项目类路径中。此外,您需要将工作区更改为项目所在的文件夹,这样它就不会制作项目的第二个副本并使用实际文件。

回答by rosejn

It's hard to be definitive about this without going through the latest version of every IDE plugin for Clojure, but as someone who keeps up with both Leiningen and the general IDE related developments I have not seen this functionality anywhere. The words IDE, eclipse and netbeans have not been mentioned on the Leiningen google group either, and I would assume that if someone was working on this they would mention it there.

如果不了解 Clojure 的每个 IDE 插件的最新版本,就很难确定这一点,但作为一个同时关注 Leiningen 和一般 IDE 相关开发的人,我还没有在任何地方看到过这个功能。Leiningen google group 中也没有提到 IDE、eclipse 和 netbeans 等词,我假设如果有人在做这个,他们会在那里提到它。

Leiningen is really easy to use on the command-line though, so don't be afraid to give it a try. I've been converting my projects to lein from using both ant and maven previously. The dependency tracking is really handy, and more plugins adding useful new commands are coming out every week. If you really need IDE integration one lightweight way to do it might be to add some kind of custom command command or button that just runs lein in the background.

不过,Leiningen 在命令行上真的很容易使用,所以不要害怕尝试一下。我之前一直使用 ant 和 maven 将我的项目转换为 lein。依赖性跟踪非常方便,每周都会推出更多插件,添加有用的新命令。如果您真的需要 IDE 集成,那么一种轻量级的方法可能是添加某种自定义命令命令或按钮,这些命令或按钮仅在后台运行 lein。

回答by acfoltzer

The best integration I've found is with slime-clojure via lein-swank.

我发现的最佳集成是通过lein-swank与 slime-clojure集成

Basically, you use the lein swank command to start a swank server with a Leiningen-configured classpath. Then, you connect to that swank server using M-x slime-connect, and you've got the repl good to go. Well, so long as you can deal with emacs ;)

基本上,您使用 lein swank 命令启动带有 Leiningen 配置的类路径的 swank 服务器。然后,您使用 Mx slime-connect 连接到那个 swank 服务器,并且您已经获得了很好的 repl。好吧,只要你能处理 emacs ;)

回答by woodings

I've been using Intellij IDEA + La Clojure.

我一直在使用 Intellij IDEA + La Clojure。

  1. Run lein pomto create a pom.xmlfile for Maven.
  2. Create a new project in Intellij IDEA and select create from Maven project.
  1. 运行lein pom以创建pom.xmlMaven 文件。
  2. 在 Intellij IDEA 中创建一个新项目并选择从 Maven 项目创建。

When you change the dependencies with Leiningen, update the pom.xml.

当您使用 Leiningen 更改依赖项时,请更新pom.xml.