Fork me on GitHub
#beginners
<
2024-03-18
>
quan xing03:03:24

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}}

seancorfield04:03:15

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.

seancorfield04:03:54

The Practicalli aliases no longer include :project/uberjar because of that: https://github.com/practicalli/clojure-cli-config/blob/main/deps.edn

seancorfield04:03:58

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.

seancorfield04:03:12

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

seancorfield04:03:44

(I don't know where you got :omit-source from -- depstar never supported that)

quan xing05:03:24

Thanks. I'm going study to for it

phill10:03:31

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.

Omer ZAK13:03:08

Is there any idiomatic, efficient and standard way to implement a bidirectional map in Clojure? Assume that the map is bijective.

Stefan Langwald13:03:39

so, :key :val -> :val :key basically?

Bob B14:03:17

<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)

ghadi14:03:56

what's wrong with using a plain map and assoc'ing both rels?

ghadi14:03:07

(assoc m a b b a)

👀 1
1
Omer ZAK14:03:56

What is wrong with a plain map and assoc'ing both rels? More memory is consumed.

💯 1
Bob B15:03:18

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.

Bob B15:03:23

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

jpmonettas16:03:06

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 ?

Vincent21:03:48

Space is cheap

Vincent21:03:52

and Space is forever

Vincent21:03:59

(2 different kinds of space 😅 )

dharrigan20:03:49

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?

Noah Bogart20:03:13

(let [old {:a [{:b "c"}]}
      given [{:d "e"} {:f "g"}]]
  (update old :a into given))

1
Noah Bogart20:03:16

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.

dharrigan20:03:13

fantastico! works a charm.

👍 1