This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-11
Channels
- # announcements (4)
- # babashka (50)
- # beginners (45)
- # cider (12)
- # clara (1)
- # clj-commons (6)
- # clj-kondo (3)
- # cljdoc (3)
- # cljs-dev (44)
- # clojure (19)
- # clojure-europe (15)
- # clojure-france (1)
- # clojure-nl (13)
- # clojure-portugal (4)
- # clojure-uk (6)
- # clojurescript (3)
- # conjure (3)
- # cryogen (10)
- # datomic (23)
- # emacs (9)
- # fulcro (12)
- # graalvm (1)
- # graphql (2)
- # introduce-yourself (2)
- # jobs (4)
- # jobs-discuss (9)
- # lsp (2)
- # pathom (3)
- # polylith (23)
- # portal (1)
- # reagent (14)
- # releases (4)
- # remote-jobs (3)
- # shadow-cljs (1)
- # sql (8)
- # tools-build (7)
- # tools-deps (10)
- # xtdb (7)
What is the process for making a java lib work with bb? I want to extract text from a pdf so I’m trying to use https://github.com/dotemacs/pdfboxing but it seems to fail when importing a java lib…
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Unable to resolve classname: org.apache.pdfbox.pdmodel.PDDocument
Location: pdfboxing/common.clj:3:3
----- Context ------------------------------------------------------------------
1: (ns pdfboxing.common
2: (:require [ :as io])
3: (:import java.io.File
^--- Unable to resolve classname: org.apache.pdfbox.pdmodel.PDDocument
4: org.apache.pdfbox.pdmodel.PDDocument
5: org.apache.pdfbox.io.RandomAccessFile
6: org.apache.pdfbox.pdfparser.PDFParser))
7:
8: (defn try-get-as-pdf
----- Stack trace --------------------------------------------------------------
pdfboxing.common - pdfboxing/common.clj:3:3
pdfboxing.text - pdfboxing/text.clj:2:3
@U7KPK060K Unfortunately Java libraries with custom classes don't work with bb, unless they are built into bb. This restriction comes from GraalVM native-image. Ways to work around this: 1. shell out to another program which can do the task you are after 2. write a babashka pod that wraps the Java library 3. use #nbb which is similar to #babashka but gives access to all Node.js libraries without any restrictions 4. Or of course, just use JVM Clojure
@U7KPK060K I made this example in #nbb https://github.com/borkdude/nbb/blob/main/examples/pdfjs/example.cljs FWIW :)
Haha I just setup the same thing but with jvm clojure and it took over a minute to run (on a fast machine!) Your nbb demo takes like 3 seconds, it's a great use case for it I think
my bb test script is this if relevant
(require '[babashka.deps :refer [add-deps]])
(add-deps '{:deps {pdfboxing/pdfboxing {:mvn/version "0.1.14"}}})
(require '[pdfboxing.text :as text])
(text/extract "hello.pdf")
Hi! Appears babashka does not have javax.security
and hence, digest
is not available. What would be a suggested approach to create a digest for a stream I have in memory?
Whoops, its there? 😲
So appears only parts of javax.security
are missing. Thought it is the whole package due to.
user=> (require 'digest)
java.lang.Exception: Unable to resolve classname: java.security.Provider [at digest.clj:6:3]
user=>
@U06FLL69W Ah you mean, you want to load the Clojure library digest
?
Yes, was just trying the library and hoping for the best. Already shelling out to sha1sum
, but that's a bit ugly. 😂
@U06FLL69W you can just use interop on MessageDigest directly
but I forked the library and made it babashka compatible now: https://github.com/babashka/clj-digest
This commit did the trick: https://github.com/babashka/clj-digest/commit/b4a30c2848dc9bd1f8ea7265b9b262e552f97929
I added the necessary classes to bb now so the original library can also be run from source in the future
Awesome. Pulling it in via deps
works now. deps
should probably default to {}
instead of complaining Manifest type not detected
😉 /cc @U064X3EF3
Hi, I wonder to know what is the best option to run two bb parallel tasks but trigger the second one only if a file generated by the first task exists?
The thing is that this two tasks are blocking: 1. shadow-cljs watch app 2. webpack server
Without parallel
the second task will be never started, right?
ok thanks, I try this!
oh it's wait-for-path: https://github.com/babashka/babashka/blob/8b8ba47f65b8c392b367d6b164bd84f5c1bd6d39/src/babashka/wait.clj#L73
Cool thanks
It works perfectly thanks!
{:tasks
{:requires
([babashka.wait :refer [wait-for-path]])
dev {:doc ""
:task (run '-dev {:parallel true})}
-dev {:depends [dev:cljs dev:webpack]}
dev:cljs {:doc "Runs Shadow-cljs watch"
:task (shell "npx shadow-cljs watch app")}
dev:webpack {:doc "Runs Webpack dev server"
:task (when (wait-for-path "target/index.js")
(shell "npx webpack server -c webpack.config.js"))}}}
Hey there! Can you please let me know if it's possible to have two projects sitting next to each other, with a bb.edn
file in each of them, and one project's tasks to depend on tasks from the other project?
@U9ES37CSZ This is currently not yet supported (similar to how you cannot do this with Makefiles). But you can have one root bb.edn
and use :dir
to execute shell and clojure commands in subdirectories, if that helps
The other option is to split out common code into a library and use :local/root
to share that code between projects
Thank you for the ideas @U04V15CAJ 🙏