Fork me on GitHub
#babashka
<
2023-10-16
>
Steffen Glückselig08:10:09

Is there a way to create a "super-uberjar", where also babashka's internal dependencies are included? I'd like to be able to use my babashka-scripts in a java-app without further dependencies.

borkdude09:10:51

Sure, create a deps.edn with bb print-deps , then add a dependency on that deps.edn using :local/root in bb.edn and then create an uberjar using bb uberjar

🙏 1
borkdude09:10:06

but if you are building a Java app you could also decide to create a pom.xml from that deps.edn instead

borkdude09:10:24

not sure about that option since I don't work a lot with maven

Steffen Glückselig10:10:40

I like the super-uberjar better - that way only that dependency has to be added to the app...

CarnunMP10:10:32

Let's say I have a /bin/script.clj somewhere on my machine, and a ~/.bb/script.clj symlink to it. There is a /resources/foo.edn that the script needs to read, even when called via the symlink. Is there an idiomatic way to make sure the foo.edn filepath is right? Or is it necessary to, say, shell out to readlink? :thinking_face:

CarnunMP10:10:25

Fwiw I have already tried (a few days ago, so just loading the context back up now 😛) a number of things, including: • (def x) (.getParent (io/file (:file (meta #'x))))*file*(io/resource "foo.edn") • and a bunch of stuff from babashka.fs

CarnunMP10:10:09

But these all seem relative to the symlink directory.

borkdude10:10:16

@U018D6NKRA4 You can use fs/real-path to follow a symlink

borkdude10:10:34

or fs/canonicalize to both turn a relative path into an absolutate path and follow symlink

borkdude10:10:57

io/resource only applies to the classpath

CarnunMP10:10:46

I'm getting a java.nio.file.NoSuchFileException on calling (prn (fs/real-path "foo.edn")) (and variants, e.g. "../resources/foo.edn") via ~/.bb/script.clj. Am I missing something crucial here about how bb builds the classpath? (Maybe I'm missing a /bin/bb.edn with a :paths?)