Compiling Java sources with Clojure deps.edn.

huangapple go评论93阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年8月12日 20:48:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/63376869.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定