Fork me on GitHub
#tools-deps
<
2019-03-02
>
nbenketaf02:03:28

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 ?

nbenketaf02:03:32

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

hiredman03:03:24

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"

hiredman03:03:12

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

nbenketaf03:03:37

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

seancorfield03:03:48

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

seancorfield04:03:23

Another option is this:

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

nbenketaf05:03:23

@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

seancorfield05:03:35

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.

seancorfield05:03:14

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.

nbenketaf10:03:17

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