This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-18
Channels
- # announcements (1)
- # babashka (17)
- # beginners (26)
- # calva (7)
- # clj-kondo (57)
- # cljdoc (8)
- # clojure (6)
- # clojure-europe (26)
- # clojure-italy (1)
- # clojure-nl (1)
- # clojure-norway (52)
- # clojure-uk (4)
- # datahike (1)
- # emacs (16)
- # events (1)
- # hyperfiddle (24)
- # introduce-yourself (1)
- # jobs (8)
- # lsp (6)
- # malli (9)
- # membrane (38)
- # missionary (5)
- # polylith (26)
- # portal (4)
- # reitit (1)
- # releases (7)
- # remote-jobs (1)
How do I exclude .clj source code files when I package a program using the following command?
clojure -X:project/uberjar :jar '"target/uber.jar"' :main-class app.main
Should I add :omit-source true
to the :exe-args
, I tried, but it didn't work.
:project/uberjar
{:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
:exec-fn hf.depstar/uberjar
:exec-args {:jar "uber.jar"
:aot true}}
depstar
is deprecated (& archived) and I would strongly recommend learning to use tools.build
directly.
If you've created a app
project with deps-new
, it'll have all that built in -- so you could create a temporary new app
project and copy in parts from that into your current project.
The Practicalli aliases no longer include :project/uberjar
because of that: https://github.com/practicalli/clojure-cli-config/blob/main/deps.edn
See https://practical.li/clojure/clojure-cli/projects/package/tools-build/#build-task for more up-to-date Practicalli information on tools.build
and uberjars.
You might also find https://clojure-doc.org/articles/cookbooks/cli_build_projects/ helpful. The official documentation explains how to make an uberjar using standard tooling: https://clojure.org/guides/tools_build#_compiled_uberjar_application_build
(I don't know where you got :omit-source
from -- depstar
never supported that)
If you can make a pom.xml that lists the dependencies, then Maven with maven-shade-plugin may be another option. It is a consumer-grade tool with the settings, filters, and transformers that uberjar production has been known to require. maven-shade-plugin is weird and it is decidedly at the "easy" end of the "simple vs easy" spectrum.
Is there any idiomatic, efficient and standard way to implement a bidirectional map in Clojure? Assume that the map is bijective.
so, :key :val
-> :val :key
basically?
<https://gist.github.com/semperos/3835417> is an example of creating a map-ish type with modified behavior. Whether the lookup works exactly as desired or not is open to interpretation, but of course it can also be changed, and this example illustrates a bunch of the other interfaces that might be desired to have different behavior (counting, iterator, etc)
Depending on the unspecified requirements, it might be desirable for the count of the map to only count one entry per relation, it might be desired for calling seq
to only provide one entry per relation, etc.
memory consumption is probably a trade-off to be weighed against inverting the map for each lookup or taking a different approach that might slow down lookups or insertions... how 'efficient' a specific impl is will likely need to be weighed against the usage patterns
I guess idiomatic is going to be at odds with memory footprint efficient. Idiomatic in Clojure tends to be immutable data structures. I think if you need something more memory efficient it will depend on the specifics of the data, maybe creating a custom type that leverages the particular aspects of your data and then maybe implement Clojure interfaces to make it play nice with the rest of the functions ?
Say I have a this structure {:a [{:b "c"}]}
and I have this other structure [{:d "e"} {:f "g"}]
and i want to simply take each element out of the second vector and add each to the vector in the first structure ('a') to end up with this {:a [{:b "c"} {:d "e"} {:f "g"}]}
how might one go about this?
(let [old {:a [{:b "c"}]}
given [{:d "e"} {:f "g"}]]
(update old :a into given))
update the existing map at the key :a
, call the function into
on the current value of (:a old)
and the provided args (aka (into (:a old) [{:d "e"} {:f "g"}])
), insert the result back into the existing map.