Takes deps.edn and packs an uberjar out of it.
Add to your bash aliases:
clj -Sdeps '{:deps {uberdeps {:mvn/version "0.1.7"}}}' -m uberdeps.uberjar
Or add to your deps.edn
or ~/.clojure/deps.edn
:
:aliases {
:uberjar {:extra-deps {uberdeps {:mvn/version "0.1.7"}}
:main-opts ["-m" "uberdeps.uberjar"]}
}
Supported command-line options are:
--deps-file <file> Which deps.edn file to use to build classpath. Defaults to 'deps.edn'
--aliases <alias:alias:...> Colon-separated list of alias names to include from deps file. Defaults to nothing
--target <file> Jar file to ouput to. Defaults to 'target/<directory-name>.jar'
--main-class <ns> Main class, if it exists (e.g. app.core)
--level (debug|info|warn|error) Verbose level. Defaults to debug
(require '[uberdeps.api :as uberdeps])
(let [exclusions (into uberdeps/exclusions [#"\.DS_Store" #".*\.cljs" #"cljsjs/.*"])
deps (clojure.edn/read-string (slurp "deps.edn"))]
(binding [uberdeps/exclusions exclusions
uberdeps/level :warn]
(uberdeps/package deps "target/uber.jar" {:aliases #{:uberjar}})))
If your project has a -main
function, you can run it from within the generated uberjar:
java -cp target/<your project>.jar clojure.main -m <your namespace with main>
Given your project has a -main
function like below:
(ns app.core
(:gen-class))
(defn -main [& args]
(println "Hello world"))
You can create an executable jar with these steps:
# ensure dir exists
mkdir classes
# aot compile
clj -e "(compile 'app.core)"
# uberjar with --main-class option
clojure -A:uberjar --main-class app.core
This will create a manifest in the jar under META-INF/MANIFEST.MF, which then allows you to run your jar directly:
java -jar target/<your-project>.jar
For more information on AOT compiling in tools.deps, have a look at the official guide.
\
with /
when building on Windows #16 #17 thx @gnarrowayCopyright © 2019 Nikita Prokopov
Licensed under MIT (see LICENSE).
Can you improve this documentation? These fine people already did:
Nikita Prokopov, George Narroway, lvh & Jorin VogelEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close