README [skip ci]
This commit is contained in:
parent
ab0af85884
commit
a4ecfd075e
1 changed files with 30 additions and 18 deletions
48
README.md
48
README.md
|
|
@ -603,9 +603,11 @@ Babashka can create uberjars from a given classpath and optionally a main
|
||||||
method:
|
method:
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
$ bb -cp $(clojure -Spath) -m my-gist-script --uberjar my-project.jar
|
$ cat src/foo.clj
|
||||||
$ bb my-project.jar
|
(ns foo (:gen-class)) (defn -main [& args] (prn :hello))
|
||||||
Hello from gist script!
|
$ bb -cp $(clojure -Spath):classes -m foo --uberjar foo.jar
|
||||||
|
$ bb foo.jar
|
||||||
|
:hello
|
||||||
```
|
```
|
||||||
|
|
||||||
When producing a classpath using the `clojure` or `deps.clj` tool, Clojure
|
When producing a classpath using the `clojure` or `deps.clj` tool, Clojure
|
||||||
|
|
@ -613,32 +615,42 @@ itself, spec and the core specs will be on the classpath and will therefore be
|
||||||
included in your uberjar, which makes it bigger than necessary:
|
included in your uberjar, which makes it bigger than necessary:
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
$ ls -lh my-project.jar
|
$ ls -lh foo.jar
|
||||||
-rw-r--r-- 1 borkdude staff 4.5M Aug 19 14:45 my-project.jar
|
-rw-r--r-- 1 borkdude staff 4.5M Aug 19 17:04 foo.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
To exclude these dependencies, you can use the following `:classpath-overrides`
|
To exclude these dependencies, you can use the following `:classpath-overrides`
|
||||||
in your `deps.edn`:
|
in your `deps.edn`:
|
||||||
|
|
||||||
``` clojure
|
``` clojure
|
||||||
{:deps
|
{:aliases {:remove-clojure {:classpath-overrides {org.clojure/clojure nil
|
||||||
{my_gist_script
|
|
||||||
{:git/url "https://gist.github.com/borkdude/263b150607f3ce03630e114611a4ef42"
|
|
||||||
:sha "cfc761d06dfb30bb77166b45d439fe8fe54a31b8"}}
|
|
||||||
:aliases {:my-script {:main-opts ["-m" "my-gist-script"]}
|
|
||||||
:remove-clojure {:classpath-overrides {org.clojure/clojure nil
|
|
||||||
org.clojure/spec.alpha nil
|
org.clojure/spec.alpha nil
|
||||||
org.clojure/core.specs.alpha nil}}}}
|
org.clojure/core.specs.alpha nil}}}}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
$ bb -cp $(clojure -A:remove-clojure -Spath) -m my-gist-script --uberjar my-bb-project.jar
|
$ rm foo.jar
|
||||||
$ bb my-project.jar
|
$ bb -cp $(clojure -A:remove-clojure -Spath) -m foo --uberjar foo.jar
|
||||||
Hello from gist script!
|
$ bb foo.jar
|
||||||
$ ls -lat *.jar
|
:hello
|
||||||
-rw-r--r-- 1 borkdude staff 4682045 Aug 19 14:55 my-project.jar
|
$ ls -lh foo.jar
|
||||||
-rw-r--r-- 1 borkdude staff 7880 Aug 19 14:55 my-bb-project.jar
|
-rw-r--r-- 1 borkdude staff 871B Aug 19 17:07 foo.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want your uberjar to be compatible with the JVM, you'll need to compile
|
||||||
|
the main namespace. Babashka does not do compilation, so we use Clojure on the
|
||||||
|
JVM for that part:
|
||||||
|
|
||||||
|
``` shell
|
||||||
|
$ rm foo.jar
|
||||||
|
$ mkdir classes
|
||||||
|
$ clojure -e "(require 'foo) (compile 'foo)"
|
||||||
|
foo
|
||||||
|
$ bb -cp $(clojure -Spath):classes -m foo --uberjar foo.jar
|
||||||
|
$ bb foo.jar
|
||||||
|
:hello
|
||||||
|
$ java -jar foo.jar
|
||||||
|
:hello
|
||||||
```
|
```
|
||||||
|
|
||||||
## System properties
|
## System properties
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue