Fork me on GitHub
#tools-deps
<
2019-05-09
>
kszabo10:05:05

hey, how do you manage compilation of Clojure :gen-class files with tools.deps at development time? Do you call clojure.core/compile manually?

seancorfield17:05:45

{:deps {org.clojure/clojure {:mvn/version "1.10.0"}}
 :paths ["classes" "src"]
 :aliases 
 {:compile {:main-opts ["-e" "(compile,'cfml.struct)"]}
  :build {:extra-deps {seancorfield/depstar {:mvn/version "RELEASE"}}
          :main-opts ["-e" "(compile,'cfml.struct)"
                      "-m" "hf.depstar.jar" "cfml-interop.jar"]}}}
is an example from one of my projects. I run it with clj -A:compile to get a REPL or clj -A:build to create a JAR for deployment. It duplicates the compile call in both. I could just have it in :compile but then I'd have to remember clj -A:compile:build whenever I wanted to build a JAR.

馃憤 4
kszabo09:05:53

Thanks! We have a bit more complicated project with shadow-cljs + deps.edn with docker images. Since we already had a Makefile to run docker-based integration tests locally, we just added a new target to it, essentially doing what you are doing above with a manual clojure invocation.

hlolli14:05:41

in leiningen there's a possibility of defining native paths with :native-path, that causes all files on this path to be spit'ed out into the current working directory, which suites well for jna/jni apps using .so files, I'm not seeing this behaviour in tools.deps, is it missing, not implemented or am I missing an argument?

hlolli15:05:55

very nice, thanks!

馃憤 4
alexmiller14:05:28

Not implemented

hlolli15:05:18

prima 馃檪 no stress, then I'll continue to advise to Overtone users to stick with leiningen until then

seancorfield17:05:45

{:deps {org.clojure/clojure {:mvn/version "1.10.0"}}
 :paths ["classes" "src"]
 :aliases 
 {:compile {:main-opts ["-e" "(compile,'cfml.struct)"]}
  :build {:extra-deps {seancorfield/depstar {:mvn/version "RELEASE"}}
          :main-opts ["-e" "(compile,'cfml.struct)"
                      "-m" "hf.depstar.jar" "cfml-interop.jar"]}}}
is an example from one of my projects. I run it with clj -A:compile to get a REPL or clj -A:build to create a JAR for deployment. It duplicates the compile call in both. I could just have it in :compile but then I'd have to remember clj -A:compile:build whenever I wanted to build a JAR.

馃憤 4
borkdude18:05:13

is this kind of thing possible with tools.deps? https://stackoverflow.com/a/24949419/6264 I imagine it鈥檚 just a -e expression?

seancorfield18:05:17

(! 1084)-> clj -e '(set! *assert* false)' -r
false
user=> (assert false)
nil
user=> (assert true)
nil
user=> ^D

Thu May 09 11:40:55
(sean)-(jobs:0)-(~/clojure)
(! 1085)-> clj -e '(set! *assert* true)' -r
true
user=> (assert false)
Execution error (AssertionError) at user/eval138 (REPL:1).
Assert failed: false
user=> (assert true)
nil
user=> 

seancorfield18:05:44

Why "imagine" when you can just "repl"? 馃檪

borkdude18:05:08

true. I鈥檓 just wondering if there was a java property for it

borkdude18:05:39

I鈥檒l just put an assert in my code and see if it fails, thanks

seancorfield18:05:40

There's a JVM property for spec asserts.

seancorfield18:05:04

(but not regular Clojure asserts I believe)

borkdude18:05:13

yeah, that鈥檚 why I imaged there would be one for regular asserts as well

borkdude18:05:03

works 馃檪

borkdude19:05:08

:jvm-opts are only supported in aliases, not on the top level right? I don鈥檛 see this in the documentation and I remember asking this before

鉁旓笍 4