Fork me on GitHub
#babashka
<
2021-10-01
>
maxp06:10:38

How to build uberjar using babashka tasks and tools.build?

maxp06:10:20

Is it possible to call tools.build api directly from babashka?

borkdude06:10:18

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

borkdude06:10:58

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

maxp06:10:47

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

maxp06:10:50

thank you

lispyclouds06:10:25

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 😛

borkdude06:10:48

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

borkdude06:10:55

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

lispyclouds06:10:32

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

borkdude06:10:41

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

borkdude06:10:46

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

lispyclouds06:10:47

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

borkdude06:10:58

You can also set an env var to save it elsewhere

borkdude06:10:47

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

borkdude06:10:01

PR welcome

borkdude06:10:11

There is already an issue for it

victorb07:10:54

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

borkdude08:10:04

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

victorb21:10:37

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

practicalli-johnny11:10:10

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

Dig14:10:50

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.

Dig14:10:33

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

borkdude11:10:37

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

borkdude11:10:39

There is also a vault library that is compatible with bb

borkdude12:10:35

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

practicalli-johnny12:10:27

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

borkdude12:10:57

@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.

practicalli-johnny15:10:55

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.

practicalli-johnny06:10:54

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

Dig18:10:24

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.