Hello, if I understood, I have to include build.clj into src path of my project. I don´t know if it´s a dumb question but, when I try to run clj -T:build uber it´s getting Namespace could not be loaded: build. What am I missing?
tools.build normally expects the build.clj file in the root of the project, although I think src should work too. do you have (ns build ...) in the file?
hello, yes . I´ll change it to root of project and try again
it seems that in src it´ll not work.
maybe add :extra-paths ["src"] to the build alias
if you really want to have it under src
no, I´m not
As mentioned above, running a tool with -T removes the project :paths and :deps. Using -T:build will use only the :paths and :deps from the :build alias. The root deps.edn is still included, which will pull in Clojure as well (but it would also come in as a dependency of tools.build). The :paths are not specified here, so no additional paths are added, however, -T includes the project root "." as a path by default.
So executing clj -T:build jar will use an effective classpath here of:
"."
clojure (from the root deps.edn)
tools.build (from the :build alias :deps)
the transitive dependencies needed by clojure and tools.buildYes, that because I use
(ns build
(:require [clojure.tools.build.api :as b]))
(def lib 'mylib/lib)
(def version (format "1.2.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def uber-file (format "target/%s-%s-standalone.jar" (name lib) version))
(defn clean [_]
(b/delete {:path "target"}))
(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
:main 'mylib.core}))Good luck, the explanation is above in the documentation :)
thank you for your time
I changed from depstar to tools.build and I observe that the final uberjar increase 20 Mb. What do you think is going to be?
I mean, as a rough sanity check maybe just count the files in both
jars are zipfiles, and can be created with varying levels of compression as well
so, do you think the difference is that one is zipped and the other not?
I dunno, I would start by checking the file counts
something like jar -tf your-uberjar.jar|wc -l