Fork me on GitHub

When using clojure -Spom, is there a way to specify the version number generated for the project? It seems to be a constant of '0.1.0'.


The whole idea is that if there is a pom, it updates in place. Just change it to whatever you want.


Otherwise there would need to be 100 flags for every piece of data


It only updates dependencies, repostories, and source paths


@tstout In case it's helpful for the next project you create, if you use clj-new to create a (library) project, it generates a pom.xml that is "complete" and you can specify the initial version to use (and other things) via command-line arguments when you create the project:


clojure -A:new lib tstout/myapp -e version=1.0.0 -e developer="Mr Stout"



      <name>Mr Stout</name>


Thanks for the responses. My use case is invoking clojure -Spom and then depstar in a Dockerfile so that the manifest in the uberjar will have a version. My employer has a standard such that all services have an /about endpoint which responds with various useful bits of info, including the build version. I am attempting to get the build version from the uberjar manifest in order to properly respond to the /about request at runtime using the functionality of java.util.jar.Manifest. Perhaps there is an easier path to supply this information to the docker image.


@tstout What I tend to do in such situations is to have the version in a file that is both part of the application itself and also used to build the application, so it would require some process to read the version file, modify the pom.xml, and then invoke depstar to build the uberjar.


At work, we specifically bake in a git-related version: we use last tag + commits + SHA which we get with git describe --tags and our wrapper around invoking depstar runs that commands and then writes the value to the pom.xml and also to an EDN file in the resources of the app -- and then runs depstar.


That way our apps can report their actual "build" version easily.


I have a lein question.


why in this file the profile :session-example is specified as a list instead of a map as in this line:


Just wanted to share this for those (like me) who have to deal with protobuf from clojure, as it might be handy: The one thing though I'd like is to avoid the runtime reflection, but I guess (from what I rad from protobuf's docs) that's probably not possible if class is not known beforehand...


How do I get access to the ring request object inside a Compojure API handler. My handler looks like this: (GET "/me" [] :summary "Get current User object" (user-handler)) Inside the user-handler function definition I want access to the Ring request object, so that I can read the user object from the session details. Thanks!


“request” is available in endpoint definitions via the request var, you can define your method as follows

(GET "/me" request (user-handler request))

👍 4

How would I go about sorting by dates in different directions? for example - sorting by :start-time ascending and :end-time descending (using java-time). The solution I have right now is:

(compare [(:start-time thing-1) (:end-time thing-2)]
         [(:start-time thing-2) (:end-time thing-1)])


but that doesn’t seem ideal


How do I set jvm-opts for a deps.edn project where it runs without using -O argument? I am using Calva so I can set a jackInEnv. However I want it to work for any environment.

Eamonn Sullivan12:02:54

Do deps.edn projects know to read the project-specific .jvmopts file, maybe?


You can't define jvm opts at the top level, you always need an alias loaded


but you can wrap clj executable into your own script wich will try to detect local .jvmopts file or will use any other logic to get jvm options and run clj/clojure binary with a set of -J%java opt% arguments


Also: Calva has a setting named jackInEnv that can be used for setting JVM options. (EDIT: And now I read the OP more carefully... never mind me...)


Wrapping clj wouldn't make it work for everyone


placing wrapper into preject-related bin directory should work for everyone


but I agree that this feature could be implemented in clojure executable. It will be handy in many cases


But you would need to configure emacs, etc to look in there.


It's a lot of fiddling


I don't think activating an alias for development is that big of a deal.


Am I missing something?

{:deps {......}
 :aliases {:dev 
           {:jvm-opts ["-Djdk.attach.allowAttachSelf"]}}}


I’m looking for use this library But also was wanting to experiment with heap size


Suddenly started working. Didn’t change anything lol


does anyone know of a good library for accessing google docs, specifically google sheets? I'd love to find something like docjure


I suppose what might be nice is something that hits the JSON http directly rather than wrapping the java, but idk


I have been using the Java SDK and it works well (``)


@U963A21SL cool. thx for the recommendation


I want to write a parser for a simple text file format that's read line-by-line, so the parser really only has to parse a line and then put the data into datascript. The two main options I see for parsing are instaparse and using clojure.spec's conform to parse, which is the better option?


or parser combinators like parsatron


For parsing, use instaparse. Spec is not intended to be used for parsing.


instaparse is nice to get something quickly, but if you need to process loads of data, you might get into performance issues. spec is not designed to work with text, although you can get it working. don't expect superb performance. hand-rolling a parser is imo the best way long term


@nihilazo to see what I mean, check out this advent of code puzzle which I solved using 4 different parsers, including instaparse and spec:


of course it will depend on your specific domain and workload what makes sense


if you need to parse clojure-ish code, use tools.reader etc.


what I'm parsing is a very simple text file format (that's also changable to make parsing easier, if I need to) so writing my own parser using string tools wouldn't be too difficult


also, I'm storing a bunch of data (basically, a file name and the tags assocated with it, that I then filter by tags) and I'm thinking of using datascript to keep this data during runtime, but there might tens or hundreds of thousands of files. I don't want to use a database server, but is datascript up to that task or not?


is this server side or in the browser?


this is a CLI application (which already is not ideal clojure territory, I know)


datahike might also be an option (#datahike).


@nihilazo Imo Clojure is very good for creating CLI applications.


or sqlite. just try it out, if it doesn't scale, try something else. 🙂


main issue is startup time, although I'm looking into graal to try and help with that


@nihilazo fwiw I'm using transit in clj-kondo (also a CLI compiled with graalvm) to do a database-like thing for storing arities, etc. about clojure functions


it's not really a database, but it is a dataset


@nihilazo Another idea: you can write a script with babashka (fast startup while still having access to much of the JVM Clojure ecosystem) and access a sqlite database by shelling out:


(sorry, I keep just saying thanks, but thanks)


I'll try using datahike first, it seems like about what I need, and then I'll try sqlite if that doesn't work out


golang is nice for CLIs.


I was going to write this in rust, but I decided to stick with what I was familiar with (this is for a tool that me and maybe 4 other people might use, so it's not a massive deal)


@nihilazo This just got announced: in #announcements. Might also be interesting for you.

Guillermo Ithier21:02:18

Hello Clojurians, I'm having a problems getting access to a zero-token through a POST so that I can use it in my buffer to perform an authentication request. Now the URL here's the link ; following along a video 'Microservices with CLojure'.  I'm lost on how to use this site to create a way to well, access to a zero-token through a POST so that I can use it in my buffer to perform an authentication request. Here is the relevant functions that calls the outdated api: (defn auth0-token []
  (let [ret
        (client/post ""
                     {:debug false
                      :content-type :json
                      :form-params {:client_id (System/getenv "AUTH0_CLIENT_ID")
                                    :client_secret (System/getenv "AUTH0_SECRET")
                                    :grant_type "client_credentials"}})]
                                  (json/parse-string (ret :body))))
Can someone help me with this? Thank you in advance 🙂


@guillermoithier Please don't cross-post the same question here as #beginners -- just be patient and wait for someone to respond.


Hi! Has someone a EBNF for XML, that I could just plug into Instaparse?


why not just use an xml parser?


just to try for learning; (what are the recommended xml parsers for Clojurescript?)


probably some JavaScript library?


maybe the browser already has what you need (if that's your target)?


ok, thanks


any tips on how to solve this reflection warning? > Reflection warning, /blabla/notification/ports/emailer.clj:79:7 - call to method withToAddresses on can't be resolved (argument types: clojure.lang.IPersistentVector). the code that generates it:

(defn- ^Destination notification->destination
  [{::spec.notification/keys [^String destination]}]
  (-> (Destination.)
      (.withToAddresses [destination])))
and the method signature:
 [this java.util.Collection]
 [this java.lang.String[]]
I tried annotating it with everything already :man-facepalming:


aha! nvm. I was trying to annotate the vector but TIL that it doesn't work. annotating a symbol and passing it to the method works


I really like the thought process behind datafy/nav but I'm having trouble understanding the intuition behind the v argument of nav (i.e.,

(nav coll k v)
(nav coll k) I would understand, but I don't really understand the v. Is it just usually omitted in most case and it's just there if you need it?


To put it another way, if I already have the value v, what do I need nav for?


@goomba (nav coll k v) returns v in a lot of cases.


But it is a consistent API for navigating from "data" to "things".


For example, in next.jdbc (and the experimental datafy/`nav` support in, if you (nav row :foo_id 42) it will fetch the row from table foo that corresponds to id = 42 -- so it needs both k and v.


ahh that makes sense


(there's an optional schema behind next.jdbc that lets you override the default conventions)


And in many cases, you'd end up calling (nav data nil v) because there's no index/key association for the v part of data (such as a sequence)


Aha. So if there's no index/key association, we'd use nil for k. I would've thought v would be nil but I wasn't thinking about it in terms of index == value I was thinking in terms of (get coll k). That's an excellent explanation @seancorfield, much appreciated


For others here thinking about datafy/`nav`, maybe this chapter of the next.jdbc docs helps