Fork me on GitHub
#tools-build
<
2022-11-25
>
jumar09:11:40

I haven't been using tools-build much in the past so I'm trying to learn it a bit. I've just generated a new project using clj-new

clojure -Tclj-new lib :name myname/mylib
Now, I can run a REPL within my Emacs (Cider) and play with the app. However, I'm wondering how should I iterate on the build script itselfs (build.clj)? When I run the standard repl build-clj isn't available. Should I run clj -A:build?

jumar09:11:41

If I do that I don't seem to be able to require the build ns:

clj -A:build
...
(require 'build)
Execution error (FileNotFoundException) at user/eval1 (REPL:1).
Could not locate build__init.class, build.clj or build.cljc on classpath.

jumar10:11:41

The guide says this: https://clojure.org/guides/tools_build > • This is just normal Clojure code - you can load this namespace in your editor and develop it interactively at the REPL. But it doesn't say anything about how to do that. Using clj -A:build I can at least require tools.build API:

(require '[clojure.tools.build.api :as b]
But what about the build ns itself?

jumar10:11:50

Looking in the cider docs now I tried: https://docs.cider.mx/cider/basics/middleware_setup.html#using-tools-deps

:cider-build {:deps {io.github.seancorfield/build-clj
                       {:git/tag "v0.8.2" :git/sha "0ffdb4c"}}
                ;; see 
                ;; - check  for the newest version
                :extra-deps {cider/cider-nrepl {:mvn/version "0.28.7"}}
                :main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]
                :ns-default build}
Then
clj -M:build
nREPL server started on port 52326 on host localhost - 
Then cider-connect from within Emacs. That kinda works I suppose - it's a bit tricky to manage but standard app REPL and the "build" REPL but it seems to be loading.

borkdude11:11:30

@U06BE1L6T You can explicitly add the current dir the the classpath with :paths ["."]

borkdude11:11:04

or you can do this: clj -Scp $(`clojure -Spath -A:build:whatever-else` )

jumar13:11:36

Oh I see, then maybe it's better to move build.clj to a separate directory (like build/build.clj)

seancorfield20:11:56

Or just eval the build.clj file in your editor -- it shouldn't matter whether it's on the path or not.

👍 1
jumar04:11:52

Yes, once i got cider repl working that became a perfect alternative:)

jumar05:11:03

Btw. Thanks Sean for the tooling around deps. I also found deps-new and ended up using it The other tool I liked was tools.project from Exoscale but it was quite slow when executing build tasks and looked less flexible/ more opinionated

1