Fork me on GitHub

Hi there, can I mix clojure and java files in the same tools deps project ? Like :path ["src" "java-src"] where src contains clojure source files and java-src java source files, and then import the classes from java source files directly in a clj source file ?


ok thanks, are there some external tools/libs that can achieve that or is it planned in the tools deps roadmap ?


as far as I know it is positively not on the road map, java requires compilation before you can use it, a build step, and tools.deps is positioned as "not a build tool"


I would be kind shocked if there isn't a tool someone wrote for it, but I don't know of one off hand


Maybe I can handle that with the “full-stack-clj-example” above, integrating leiningen as a lib, thanks anyway 🙂


@nbenketaf Or you could, you know, run javac on your Java code, and then run clj...


Another option is this:

[email protected]:~/clojure/jc$ ls
[email protected]:~/clojure/jc$ clojure -e "(require '[ :refer [sh]])(sh \"javac\" \"\")(shutdown-agents)"
{:exit 0, :out "", :err ""}
[email protected]:~/clojure/jc$ ls
[email protected]:~/clojure/jc$


@seancorfield thank you for the inputs, here is the larger problem I am trying to solve : I have a forked project A initially managed with lein which includes some java files. I tried to convert this project to a tools deps one, basically I added a deps.edn file. Then I have another project B that declares a deps to project A with a git/url coordinate, and it’s in project B where I need the compiled java code. I guess I should package my forked project A, and use the mvn coordinate instead


Yeah, if a dependent project has code that needs to be compiled, either you need to package it as an "artifact", or you'll need to bring it down as source and compile stuff yourself.


Java source projects pretty much require compiled artifacts for use. Clojure is trying to get away from that by allowing source projects to be used as-is.


Ok i see, thank you for taking the time answering 🙂