This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-24
Channels
- # announcements (30)
- # asami (9)
- # babashka (37)
- # beginners (120)
- # calva (26)
- # cider (3)
- # clara (9)
- # clj-commons (7)
- # clj-kondo (17)
- # cljsrn (2)
- # clojure (32)
- # clojure-europe (56)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (4)
- # clojurescript (34)
- # conjure (1)
- # copenhagen-clojurians (8)
- # core-async (21)
- # cursive (2)
- # datahike (2)
- # datascript (5)
- # events (4)
- # fulcro (32)
- # graalvm (10)
- # heroku (3)
- # introduce-yourself (1)
- # jobs (2)
- # lsp (3)
- # luminus (1)
- # malli (8)
- # meander (15)
- # minecraft (1)
- # nrepl (2)
- # off-topic (57)
- # pathom (2)
- # polylith (35)
- # reagent (6)
- # reitit (8)
- # releases (1)
- # rewrite-clj (7)
- # shadow-cljs (21)
- # timbre (4)
- # tools-build (1)
- # tools-deps (33)
- # vrac (8)
I have a question about how a lib’s resources get rolled up into an uberjar:
• let’s say I’m beginning a new lib under /lib/foo/
within the project, and it has /lib/foo/deps.edn
and /lib/foo/resources/hug.sql
• The outer project is consuming it using :local/root
in its deps.edn
• Let’s say using depstar or now tools.build, would the uberjar contain hug.sql
(the lib’s resource) by default?
I have a couple plot twists here (eg lein with lein-tools-deps
for … reasons), and I don’t think I understand classpath/build stuff all that well.
there is no "by default" under tools.build - either can be done, depends what you're doing
that script is copying things from resources to the classes dir which is included into the uber jar
so I think the answer is yes, it should be included
build-clj
makes some assumptions about what's "typical": copy src
+ resources
; compile src
. But in general you have complete control.
ok so the problem I’m having with my local/root lib resources not getting rolled up is probably some mismatch weirdness deep in lein-tools-deps
and I can work around it by adding "lib/foo/resources"
to the :resource-paths
in project.clj
lein-tools-deps
-- there's your problem 🙂
I archived boot-tools-deps
because it only worked in the simplest cases and just caused confusion and frustration beyond those -- and I see a lot of the same around lein-tools-deps
(although I think lein
is slightly more amenable to such surgery).
It's been about six years since I last used lein
for anything other than helping beginners with problems... 🤷:skin-tone-2:
verdict: yes, uberjar contains hug.sql
from the local/root lib. Committed the experiment in case this is useful to anyone https://github.com/rgm/experiments/tree/master/2021/09-tools-build
See https://github.com/seancorfield/build-clj#typical-buildclj-with-build-clj for a version with defaults 🙂
At work, we build our uberjars like this:
(bb/clean {})
(b/copy-file {:src version-clj
:target "target/classes/ws/uberjar/release.clj"})
(bb/uber {:main main-class :uber-file jar
:compile-opts {:direct-linking true}})
the version-clj
file is just a ns we create with a single def
that has the git SHA/tag as its value, so we can ask any uberjar what it was built from.(spit version-clj (str "(ns ws.uberjar.release)"
"(def version \"" (git-version) "\")"))
(defn git-version
"Return a git version string"
[]
(sh "git" "describe" "--tags" "--match" "b[ui][il]l[di]*"))
I do something similar for the version. The uber
task in my build.clj
writes out a version.edn
in the resources directory which is then read by the config management library (`aero` in this case) on startup.
verdict: yes, uberjar contains hug.sql
from the local/root lib. Committed the experiment in case this is useful to anyone https://github.com/rgm/experiments/tree/master/2021/09-tools-build
How can I work around a transitive dep on a https://ask.clojure.org/index.php/7836/tools-deps-does-not-handle-maven-relocations?show=7836 package? One of tess4j's deps pulls in bouncycastle/bctsp-jdk14 somewhere. How can I find which package pulls it in so I can override it?
This is not particularly easy right now
You could exclude it in all of your top level deps, then -Stree I think
Thanks, I didn't know about -Stree
I was always using trace
Oh, hmm, trace is working okay now too. I think I just messed up the exclusion earlier. Sorry about that