Fork me on GitHub
#tools-deps
<
2019-05-15
>
Chris14:05:18

Is anyone aware of a tools-deps dependency visualizer? (i.e. the equivalent of https://github.com/walmartlabs/vizdeps)

Chris16:05:49

Nevermind! It turned out to be relatively easy to write my own 🙂

richiardiandrea17:05:48

A little rusty with Clojure on JVM...if I want to work against a Java code base, do I need to include taarget in order to import classes in the REPL using clojure?

Alex Miller (Clojure team)17:05:33

yes, assuming target is the root of your compiled classes

richiardiandrea17:05:11

ok cool that's what I was missing then, I guess it goes without saying that I then need to compile the java code every time the file changes

richiardiandrea17:05:22

thank you Alex that works

Jakub HolĂ˝ (HolyJak)20:05:51

Hello, what do people use to watch for file changes to trigger actions (e.g. clojure.core/compile)? Lein certainly has a watch functionality/plugin but what about clj CLI? Thanks!

Alex Miller (Clojure team)20:05:36

as above, clj doesn't cover compilation

Alex Miller (Clojure team)20:05:43

it does cover "running programs"

Alex Miller (Clojure team)20:05:47

the compiler is a program

Alex Miller (Clojure team)20:05:00

compose programs, run with clj if you like

Jakub HolĂ˝ (HolyJak)20:05:30

thank you, Alex. My question is essentially: Does anyone made a clj-friendly plugin for watching files and executing actions upon change?

orestis13:05:28

I like hawk for this.

❤️ 4
Alex Miller (Clojure team)20:05:33

I'm not aware of something specific to tools.deps, but there several watcher type things out there

Alex Miller (Clojure team)20:05:45

last time I needed one, I just wrote the 60 lines of java interop to use the one in the jdk

Alex Miller (Clojure team)20:05:22

admittedly, it's a weird java api

Alex Miller (Clojure team)20:05:50

https://www.clojure-toolbox.com/ has a bunch of filesystem watcher libs

❤️ 4
souenzzo20:05:46

@holyjak I use (load "core") to load/reload files But usually it's a "built-in" feature from your IDE/Plugin/Editor/..

Jakub HolĂ˝ (HolyJak)21:05:41

well, I need to watch for changes to run compile automatically...

seancorfield21:05:57

Personally, I don't like watcher-based workflows. I usually find the watch fires when I don't want it to and/or gets into a bad state because it fires while there are still errors in the code.

seancorfield21:05:41

I'd much rather have an explicit compile command in a (comment ...) form that I can eval from my editor without even worrying about what the terminal is doing.

seancorfield21:05:03

(also, why do you need to run compile at all? what features are you relying on that require Clojure code to be compiled?)

Jakub HolĂ˝ (HolyJak)22:05:56

https://github.com/holyjak/clj-concordion - integration with Java Specification by Example test framework that expects me to give it Fixture objects with test-specific methods. So you do `(deffixture "class.Name" [fns2expose as methods]) for each specification document.

Jakub HolĂ˝ (HolyJak)22:05:47

good points about the downsides of watchers, thank you!

seancorfield22:05:12

Ah... so you're relying on code gen / gen-class rather than reify for this?

Jakub HolĂ˝ (HolyJak)22:05:00

exactly ,as there is no interface to reify

Jakub HolĂ˝ (HolyJak)21:05:47

Wied problem: while this works

clj -J-javaagent:bin/springloaded-1.2.5.RELEASE.jar -J-noverify
this fails:
; deps.edn: [...]
:aliases {:agent {:jvm-opts ["-J-javaagent:bin/springloaded-1.2.5.RELEASE.jar" "-J-noverify"]}}
; CLI:
$ clj -O:agent
Unrecognized option: -J-javaagent:bin/springloaded-1.2.5.RELEASE.jar
Why?

✅ 4
seancorfield21:05:26

-J passes options through. They don't start with -J inside :jvm-opts

👍 4
seancorfield21:05:46

You want

:aliases {:agent {:jvm-opts ["-javaagent:bin/springloaded-1.2.5.RELEASE.jar" "-noverify"]}}

Jakub HolĂ˝ (HolyJak)21:05:03

oh I see, please ignore 🙂 I have to omit -J

Jakub HolĂ˝ (HolyJak)21:05:34

Given a .clj file path, what is the simples way of finding out the namespace of the file? I could read the first line and check for #"\(ns (\w+)" but there is surely a cleaner way?

seancorfield21:05:48

There's no guaranteed way because you can change namespaces inside a file and you can load arbitrary source files into another namespace.

seancorfield21:05:19

The convention is path/to_the/file.clj => path.to-the.file tho' -- note the _ to - mapping. And you'll need to know what it is _relative to your classpath_ because if src/main is on your classpath, src/main/path/to_the/file.clj is what will get loaded if you try to require path.to-the.file

Alex Miller (Clojure team)21:05:20

tools.namespace is a lib for doing this kind of thing