英文:
Compiling Java sources with Clojure deps.edn
问题
如何配置我的Clojure CLI的deps.edn
文件,以便将Java源文件与.clj
的Clojure源文件一起编译?
我找到了badigeon,它可以编译Java源代码,但我在我的简单项目中使用时遇到了问题。
英文:
How do I configure my Clojure CLI deps.edn
file to compile Java source files along with my .clj
Clojure source files?
I found badigeon which can compile Java sources, but I'm struggling to use in my simple project.
答案1
得分: 3
你现在可以使用clojure.tools.build来执行此操作。
英文:
You can now do that with clojure.tools.build
答案2
得分: 2
The "best" way to do this currently is to separate your Java and Clojure sources into two projects. In the Java project, create a jar with the compiled classes (using standard Java tools - perhaps make
and javac
) and install the jar into your local maven repo. Then add the jar file as a dependency in the deps.edn
of your Clojure project.
You might also be able to use the jar directly, without installing locally, by using the local/root
feature in deps.edn
. See the Deps Rationale for how to do that.
Another way would be to arrange to have the Java sources compiled into a classes
sub-directory of your combined (Java / Clojure) project and then add the classes
directory to the :paths
key in your deps.edn
. The creation of the class files will (again) have to be done with Java tools or shell scripts - outside of clj
.
There are some recent developments in clj
that may make this easier in the future.
英文:
Without knowing more about your context ...
The "best" way to do this currently, is to separate your Java and Clojure sources into two projects. In the Java project, create a jar with the compiled classes (using standard Java tools - perhaps make
and javac
) and install the jar into your local maven repo. Then add the jar file as a dependency in the deps.edn
of your Clojure project.
You might also be able to use the jar directly, without installing locally, by using the local/root
feature in deps.edn
. See the Deps Rationale for how to do that.
Another way would be to arrange to have the Java sources compiled into a classes
sub-directory of your combined (Java / Clojure) project and then add the classes
directory to the :paths
key in your deps.edn
. The creation of the class files will (again) have to be done with Java tools or shell scripts - outside of clj
.
There are some recent developments in clj
that may make this easier in the future.
答案3
得分: 0
clj
不会这样做。
lein
执行许多超出clj
命令行范围的操作。
您可能会找到一些可以执行此操作的库,然后可以调用clj -m lib-that-compiles-java
。
英文:
clj
will not do that.
lein
do a lot of things that are out-of-scope for clj
command line.
You may find some library that do that, then you can call clj -m lib-that-compiles-java
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论