This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-09
Channels
- # announcements (3)
- # asami (1)
- # babashka (19)
- # beginners (84)
- # calva (3)
- # cider (5)
- # clj-commons (22)
- # clj-kondo (31)
- # cljdoc (4)
- # cljs-dev (5)
- # clojure (65)
- # clojure-australia (1)
- # clojure-europe (44)
- # clojure-nl (2)
- # clojure-uk (2)
- # clojurescript (18)
- # code-reviews (12)
- # conjure (2)
- # core-async (12)
- # data-science (1)
- # datomic (47)
- # deps-new (1)
- # emacs (2)
- # events (4)
- # fulcro (35)
- # integrant (1)
- # jobs (5)
- # jobs-discuss (10)
- # london-clojurians (1)
- # lsp (13)
- # music (1)
- # nextjournal (1)
- # off-topic (11)
- # parinfer (3)
- # pathom (6)
- # polylith (11)
- # portal (41)
- # re-frame (4)
- # reagent (13)
- # reitit (8)
- # remote-jobs (3)
- # sci (18)
- # shadow-cljs (34)
- # spacemacs (3)
- # tools-build (12)
- # tools-deps (6)
- # vim (2)
- # xtdb (7)
Using this script
(ns build
(:require
[clojure.tools.build.api :as b]
[org.corfield.build :as bb]))
(defn -main
"Builds an uberjar"
[& _]
(let [class-dir "target/classes"
uber-file "target/ic-standalone.jar"
opts {:class-dir class-dir
:compile-opts {:direct-linking false}
:main 'company.web.server.main
:uber-file uber-file
:exclude ["license(.)*"]}]
(b/delete {:path class-dir})
(bb/uber opts)
(println "Uberjar is built.")
opts))
I get an uberjar but one of the namespaces that is loaded dynamically isn’t therebb/uber will compile things in your :src-dirs
@emccue One of the namespaces in your own codebase? Is it under src
or some other folder? bb/uber
does
(println "Copying" (str (str/join ", " src+dirs) "..."))
(b/copy-dir {:src-dirs src+dirs
:target-dir class-dir})
I think you need to set :src-dirs then to include it in compilation
Ah, OK, you need to tell the build about that then -- by default it just uses src
.
is there a way to pull it out of the deps edn’s basis or is this just a place i need to specify
bb/uber
assumes src
+ resources
for copying but you can override :src-dirs
and :resource-dirs
for bb/uber
.
bb/uber
is just a shorthand for what's in the tools.build
Guide:
(defn uber [_]
(clean nil)
(b/copy-dir {:src-dirs ["src" "resources"]
:target-dir class-dir})
(b/compile-clj {:basis basis
:src-dirs ["src"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file uber-file
:basis basis}))
If you want additional files copied into the classes folder, you need to tell the build about it.
Add it to your opts
hash map in your -main
(kind of weird to use -main
in build.clj
BTW -- the expected usage is clojure -T:build <task>
).