This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-20
Channels
- # adventofcode (17)
- # announcements (1)
- # aws (1)
- # beginners (102)
- # calva (27)
- # cider (16)
- # clj-commons (34)
- # clj-kondo (33)
- # cljs-dev (5)
- # cljsrn (4)
- # clojure (124)
- # clojure-europe (17)
- # clojure-nl (8)
- # clojure-spec (13)
- # clojure-uk (6)
- # clojurescript (68)
- # datahike (21)
- # datomic (23)
- # emacs (3)
- # fulcro (30)
- # introduce-yourself (6)
- # jobs-discuss (6)
- # lsp (31)
- # nextjournal (3)
- # off-topic (1)
- # other-languages (45)
- # portal (4)
- # re-frame (8)
- # releases (4)
- # shadow-cljs (39)
- # specter (6)
- # tools-build (18)
- # tools-deps (11)
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?
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.build
Yes, 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}))