tools-build

Jakub Holý (HolyJak) 2022-01-25T10:00:58.017600Z

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!

✅ 1
borkdude 2022-01-25T11:10:23.018100Z

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.

borkdude 2022-01-25T11:11:09.018300Z

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.

❤️ 1
🙏 1
Jakub Holý (HolyJak) 2022-01-25T12:41:41.018500Z

facepalm The : is the culprit. Thank you!

Jakub Holý (HolyJak) 2022-01-25T12:42:09.018700Z

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

borkdude 2022-01-25T12:45:06.019100Z

but why... https://clojure.org/guides/tools_build

borkdude 2022-01-25T12:45:43.019300Z

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) 2022-01-25T12:45:49.019500Z

You are of course right

Jakub Holý (HolyJak) 2022-01-25T12:47:04.019700Z

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!

👍 1
lread 2022-01-25T14:13:31.022500Z

I expect that little colon confuses many people @holyjak!

Jakub Holý (HolyJak) 2022-01-25T14:17:44.023800Z

Thank you for your psychological support :)

2
DenisMc 2022-01-25T14:14:44.023700Z

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) 2022-01-25T14:54:13.027300Z

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

Alex Miller (Clojure team) 2022-01-25T14:20:33.024900Z

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

DenisMc 2022-01-25T14:31:20.027100Z

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) 2022-01-25T14:20:52.025300Z

All the examples in the guide are doing this

Alex Miller (Clojure team) 2022-01-25T14:22:13.026800Z

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