This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-01
Channels
- # announcements (4)
- # babashka (19)
- # beginners (19)
- # calva (24)
- # cider (1)
- # clerk (7)
- # clj-otel (60)
- # clojars (22)
- # clojure (15)
- # clojure-europe (20)
- # clojure-nl (2)
- # clojure-norway (61)
- # clojure-uk (9)
- # clojurescript (18)
- # community-development (3)
- # cursive (3)
- # datahike (4)
- # datalevin (5)
- # emacs (8)
- # off-topic (23)
- # polylith (46)
- # releases (6)
- # spacemacs (8)
- # yamlscript (1)
Due mostly to my own stupidity I have nuked the physical file that I just did a bunch of work in. I still have a REPL open with the old definitions currently defined in it, and I can get the function object with the code I want to recover. Is there any way to pull up some version of the original Clojure source from the REPL?
Generally no. You could get bytecode and decompile it if suitably desparate
Ok, cool. I'm not that desperate, but thanks for the confirmation. I'll try to see if my gray matter can work as a soft backup
Fun fact, albeit unhelpful: In Emacs Lisp, functions are their data structures, so there you could have printed them out from memory. I've used this fact to extract the parameter list from the actual function definition for use in auto-generated documentation, as one example of its applicability. 😅
Not for what I need, I was working in an editor and then sending files to the repl via editor integration
I had kind of assumed there was no way to get back to the source, but also last week I pulled in some code via (def f (load-file "foo.clj"))
where foo.clj
consisted of (fn [x ] ...)
, and I was surprised to see some actual source code come back when I ran (str f)
. So I thought maybe there might be a cached version kicking around the REPL or something.
...although now I'm having trouble replicating that behavior. 🤷
How do I build a -tests.jar that includes src/test/clojure code? With pure Java and maven apparently you do this with maven-jar-plugin/test-jar
. I can’t figure out how to do with with lein or clj to get clojure test code in the -tests.jar.
With the CLI, you'd use build.clj
and just copy the test
folder as well as everything else you copy into the target folder to build the JAR.
See https://clojure.org/guides/tools_build#_compiled_uberjar_application_build :
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
Presumably in your project you have src/main
instead of src
, so you'd add src/test
to that.