Fork me on GitHub
#tools-build
<
2022-01-25
>
Jakub Holý (HolyJak)10:01:58

Hi! I am just starting with tools-build and kind of lost. I have two questions: 1. Is it correct that I need to manually install build tools with clj -Ttools install io.github.clojure/tools.build '{:git/tag "v0.7.5" :git/sha "34727f7"}' :as build ? (Before that, I got "Error building classpath. Unknown tool: build") 2. Why do I need to manually activate the build alias, is it not activated automatically? This clojure -A:build -Tbuild jar works in my project but clojure -Tbuild jar fails with "Unqualified function can't be resolved: jar" Thank you!

2
borkdude11:01:23

Typically you would just add a :build alias to your deps.edn and then invoke it using clojure -T:build uber I made a CLI called https://github.com/babashka/neil which allows you to set this up very quickly:

neil add build 
This creates build.clj and the build alias in your deps.edn using the newest tools.build version. You can immediately execute clojure -T:build uber after that.

borkdude11:01:09

Note that -T:foo and -Tfoo are two different things: the one without the colon is executing a globally installed tool, while the first is executing a tool in the alias of the deps.edn.

❤️ 2
🙏 2
Jakub Holý (HolyJak)12:01:41

facepalm The : is the culprit. Thank you!

Jakub Holý (HolyJak)12:01:09

Though no, I am actually trying to exec a globally installed tool

borkdude12:01:43

Imo it's more reproducible to depend on a specific version of tools build in your project than rely on a globally installed one

Jakub Holý (HolyJak)12:01:49

You are of course right

Jakub Holý (HolyJak)12:01:04

I should have simply executed clojure -T:build jar in my project, which works. I was confused b/c I have installed build globally - though perhaps I should not have done that. I read parts of the build guide but obviously have not grokked it and I overlooked the crucial difference between Tbuild and T:build Thank you so much!

👍 2
lread14:01:31

I expect that little colon confuses many people @U0522TWDA!

Jakub Holý (HolyJak)14:01:44

Thank you for your psychological support :)

simple_smile 2
DenisMc14:01:44

Hi, I’m working on a uberjar build for my project using the example code at https://clojure.org/guides/tools_build as a basis and I have a question related to the classpath. I understand that when you run the build alias as with -T from clojure that the default :deps in deps.edn are ignored, but does that mean that you must laboriously define the same (or slightly tweaked) list of library dependencies within the build alias again, or is there a more idiomatic way to accomplish this? Thanks in advance.

Jakub Holý (HolyJak)14:01:13

Our of topic but you could use our be inspired by https://github.com/seancorfield/build-clj

Alex Miller (Clojure team)14:01:33

No, the basis built in tools.build uses the project :deps by default

DenisMc14:01:20

Thanks for the quick response. Yes indeed, that’s the case. I was being thrown by a ClassNotFoundException related to a misconfiguration of my :paths in my deps.edn. Once I fixed that everything works. Thanks again.

Alex Miller (Clojure team)14:01:52

All the examples in the guide are doing this

Alex Miller (Clojure team)14:01:13

That is, the build is a program and that program does not need your deps. It uses the deps.edn as data to construct the set of libs (the basis) used to include in the uberjar