How do I include a local jar dependency when building an uberjar? My deps.edn looks like this:
{:paths ["src" "lib/colornote-decrypt.jar"]
:deps {cheshire/cheshire {:mvn/version "5.11.0"}
org.clojure/tools.cli {:mvn/version "1.0.219"}
babashka/fs {:mvn/version "0.4.19"}}
:aliases {:build {:deps {io.github.clojure/tools.build {:git/tag "v0.9.4" :git/sha "76b78fe"}}
:ns-default build}}}
And everything works fine when I’m runing as clj -M -m
When I build an uberjar, it throws a ClassNotFound for the class that is imported from the jar. Here’s the build.clj
(ns build
(:require [clojure.tools.build.api :as b]))
(def lib 'color-note-decryptor/decryptor)
(def version "1.0.0")
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s.jar" (name lib)))
(defn clean [_]
(b/delete {:path "target"}))
(defn uber [_]
(clean nil)
(b/copy-dir {:src-dirs ["src"]
:target-dir class-dir})
(b/compile-clj {:basis basis
:src-dirs ["src" "lib/colornote-decrypt.jar"]
:class-dir class-dir})
(b/uber {:class-dir class-dir
:uber-file jar-file
:basis basis
:main 'color-note-decryptor.decryptor}))
What am I doing wrong?:src-dirs ["src" "lib/colornote-decrypt.jar"] -- a JAR is not a directory containing (Clojure) source to compile
I would remove the JAR from :paths and add it to :deps as :local/root, then I think uber will pick it up correctly from the classpath as a regular dependency.
Wow, that was quick! And it helped, thank you so much @seancorfield