Fork me on GitHub
#babashka
<
2021-09-24
>
borkdude09:09:04

Pretty cool command line parsing in a few lines if I may say so myself :) https://github.com/clj-easy/graal-config/blob/master/build_shared.clj#L7

👀 3
🤓 1
Jakub Holý09:09:16

nice! at least until somebody messes up or there will be no-argument build flags 🙂

borkdude09:09:18

just don't use no-argument build flags

borkdude09:09:26

with this style

borkdude09:09:32

just do :force true for example

👍 1
mike_ananev10:09:23

@borkdude, hi! We have such scenario: 1. Closed environment (without Internet). Only corporate mirrors for Maven Central & Clojars 2. Corporate Jenkins CI agent with ~/.m2 is empty and read only. 3. Using mvn and pom.xml we have downloaded all deps to local project folder into .m2 folder 4. In deps.edn we set :mvn/local-repo to ".m2" value 5. clojure tools deps can use this local repo to run aliases 6. We use bb tasks. One of them requires cprop 0.1.18 which is already downloaded to local project folder into .m2. babashka (0.5.0) can't see ".m2" and trying to download deps from Internet ignoring :mvn/local-repo in deps.edn How to tell bb to use local .m2 cache in project folder?

borkdude10:09:51

@mike1452 You also need to add :mvn/local-repo to bb.edn

borkdude10:09:15

Using bb 0.6.1 is recommended

mike_ananev10:09:45

Thank you. In order to update babashkaon all corporate servers I need to pass some bureaucratic procedures, security checks, etc. 😂

borkdude10:09:20

ok, I think it should also work with the old one

borkdude10:09:05

Perhaps bb could also support something like -Sdeps so you can merge in some settings in the bb.edn on CI

borkdude10:09:30

@mike1452 Note that you can also do this: write a classpath using bb print-deps --format classpath

borkdude10:09:47

and then set BABASHKA_CLASSPATH to the contents of that in your docker image

borkdude10:09:57

(or whatever method of deployment you have)

borkdude10:09:23

in older bb where you cannot use print-deps you can get the classpath using (babashka.classpath/get-classpath)

borkdude11:09:04

hmm, you might have to transform absolute paths to relative paths though

borkdude11:09:09

anyway, that might also work

mike_ananev12:09:56

Big thank you. I'll try this

borkdude12:09:13

There is also babashka.classpath/split-classpath to split a classpath into multiple segments

borkdude12:09:49

@mike1452 something like this:

[email protected] /tmp $ cat bb.edn
{:deps {medley/medley {:mvn/version "1.3.0"}} :paths ["."]}
[email protected] /tmp $ bb -e '(->> (babashka.classpath/get-classpath) (babashka.classpath/split-classpath) (map #(str/replace %(System/getProperty "user.home") ".")) (str/join (System/getProperty "path.separator")))'
".:./.m2/repository/medley/medley/1.3.0/medley-1.3.0.jar"

mike_ananev12:09:56

Yeah, I'll take it right now

mike_ananev13:09:24

The same result - can't see jars. We run not in docker. It is pure linux. BABASHKA_CLASSPATH=".m2" All deps are in a local .m2 including cprop dep. run bb test cannot find cprop, which is required for bb.edn

borkdude13:09:23

@mike1452 BABASHKA_CLASSPATH=.m2 is not correct

borkdude13:09:47

The classpath must look something like: ".:./.m2/repository/medley/medley/1.3.0/medley-1.3.0.jar" . See the example above.

mike_ananev13:09:21

ok, I'll try to change

mike_ananev13:09:51

Now, it works! thank you.

mike_ananev13:09:07

BABASHKA_CLASSPATH=".:./.m2/cprop/cprop/0.1.18/cprop-0.1.18.jar" was correct answer

borkdude13:09:25

@mike1452 In case you didn't understand me yet: the example above generates that classpath automatically

borkdude13:09:42

So you can spit that out to a file

borkdude13:09:47

and then set the env var from that file

borkdude13:09:11

but doing it manually works too, only more work :)

borkdude13:09:32

@mike1452 You can also make an uberjar with bb uberjar code.jar

borkdude13:09:40

and then set BABASHKA_CLASSPATH=code.jar

borkdude13:09:58

this will contain all your libs + scripts

borkdude13:09:58

$ cat bb.edn
{:deps {medley/medley {:mvn/version "1.3.0"}} :paths ["."]}
bb uberjar foo.jar
bb -cp foo.jar -e "(require 'medley.core)"

borkdude13:09:20

perhaps easier

borkdude13:09:39

also works with gitlibs