Fork me on GitHub

How to build uberjar using babashka tasks and


Is it possible to call api directly from babashka?


You can check the graal-build-time project which uses + uber


Also graal-config uses it for all projects. Both under the clj-easy org


@U7ERLH6JX - btw, you can use (clojure " ..." ) instead of (shell "clojure ...")


thank you


yep i had considered it, however this runs on a CI and it needs to download things everytime and by shelling out to clojure i can cache things. i can cache the deps from bb too but got too lazy to wirte it 😛


You can’t yet use the API straight from bb. A lot of parts are compatible but the tools deps alpha stuff and compile stuff inevitably needs a JVM


@U7ERLH6JX if you use bb clojure the caching should be identical to invoking clojure from within bb


@U04V15CAJ it needs a download of deps.clj right? if i use (clojure ...)? is that also in the standard ~/.m2 path?


It downloads the tools jar on startup. This is saved in .deps.clj


It’s an uberjar so it doesn’t belong in m2. The Clojure CLI itself saves it in .clojure


yeah so this is the download that i did not cache part i was referring to 😅, now that i know it, i will add it to the list of folders to cache


You can also set an env var to save it elsewhere


I’m also considering reusing the Clojure tools jar from the already installed Clojure CLI


PR welcome


There is already an issue for it


Hello! Any libraries/pods available in Babashka for managing various time stuff? Mainly interested in taking a timestamp and making it into human readable "1 hour and 2 minutes ago" or similar


@UEJ5FMR6K java.time is available. some clojure time libs based on that work, like cljc.time.


Ooh, cljc.time will do the trick for now. Thanks a lot!


Would babashka be useful for pulling out a value from an AWS secret manager and setting a local environment variable? For example, get a database password from an AWS secret which holds host, db, password, etc values I assume a bb script would shell out to the aws CLI tool and get the JSON response, then pull out the desired value from that JSON data and then shell out create the environment variable. Does that sound reasonable / possible? Update: I could also try using the congnitect aws-api


I do it all the time in bb, it is awesome for scripting aws tasks. You can use aws-pod or just call aws cli, both ways work. I've started with wrapping aws cli and then ported to aws-pod once it was available.


Here is a simple macro to make calling aws cli esier.

Cora (she/her)11:10:08

the last bit isn't good since shelling out to create an environment variable creates a new shell which would go away after bb finishes shelling out and the value would be lost. bb could output to stdout, stderr, or a file and then the shell that ran bb can use that output to export the variable within its own shell for subsequent commands

👍 2
Cora (she/her)11:10:41

you could also use aws-cli and jq to pull this value out. or aws-cli and jet, probably

Cora (she/her)11:10:41

the aws cli tool itself is capable of doing querying of its own json responses to get just the info you need

thanks3 2

Yeah you can't set environment variables in bb, but you can however create new processes that have that env var set


There is also a vault library that is compatible with bb


@jr0cket One trick I've applied in the past is to spit bash output and then source that with bash. That's a way you can set env vars :)


writing env vars to a file and sourcing it would be nice. There is one env var I want to set most days (an auth0 token authorization token). The filter should find the right env var and set it to the new token value. I'll also try with the aws cli as it may also be useful to set env vars in the clojure REPL (to avoid having to restart the REPL).

Cora (she/her)12:10:13

I use an envrc with direnv for that, with a cache file. when the cache file is too old i recreate it


@jr0cket You can't set environment variables within a JVM process. The environment is immutable. However, you can create new processes that contain the new environment variable from that JVM process.

Cora (she/her)12:10:50

i can dig out that caching code when i'm at a computer


Hmm, I think attempts to use the bb aws-pod are failing because we use single sign-on (using aws-valut). So will need to figure that bit out before I go any further. Thanks for all the idea.


I can call babashka scripts using aws-vault like so aws-vault exec profile-name -- bb script.clj aws-valut starts the single sign-on process for my aws account and then runs the bb script I can also run a repl using aws-vault with the server flag to refresh credentials aws-vault exec profile-name --server -- clojure -M:repl/rebel


We use vault, awsadfs, sso and bunch of other techniques with aws, because of legacy reasons, all of them work with aws-pod w/o issues. As long as you can get an aws token, you can use aws-pod.