Migrate :project/jar and :project/uberjar aliases to tools.build
You have :project/jar and :project/uberjar aliases that still depend on depstar which has been deprecated (and archived) for six months.
People should be using tools.build instead, although it does require more setup (my build-clj wrapper makes it easier so perhaps that's what you could migrate :project/jar and :project/uberjar to instead?).
Thank you for the work on build-clj project, it's high on my to-do list
The plan is to move to tools.build as soon as I have had time to look at this approach in detail (should be working on this over the next few weeks)
If I understand correctly, a build.edn file is required. If so, I would need to understand at least the basics of this before switching and include a suitable config
I also plan to prioritize deps-new over clj-new (and create several templates) which simplifies the build process by providing a build.edn configuration.
Thank you.
What is build.edn? Never heard of that. Do you mean build.clj? To invoke just the uber function from the build-clj wrapper for tools.build, you can just use -T and an alias. Maybe I'll add some examples to build-clj's README...
@practicalli-john I've added some examples to the build-clj README of how you can use it via just an alias from the CLI without a build.clj file.
Using the stand-alone commands seems to require specific aliases defined, eg. to run tests then :test alias that defines the path and cognitect-labs/test-runner deps should be defined (assume this can be either project deps.edn or user level deps.edn file.
If the :test alias is renamed then the test runner namespace is not found. This is the same when using the clojure -T:build test
As build-clj looks for cognitect/test_runner.clj by default. If changing :test to use the Koacha test runner then the alias must contain a :main-opts with a value defining the main namespace. If an :exec-fn is included, then the test task will try to use cognitect/test_runner and fail as its not on the classpath. Curious as to why :exec-fn cannot be used, if that is a choice of build-clj or limitation of tools.build.
Some investigation required into tools.build and build-clj is still required.
I wasn't sure whether your last comment was "musing out loud" or some questions intended for me, which is why I didn't respond at the time. However, this feels like a question I should answer:
Curious as to why :exec-fn cannot be used, if that is a choice of build-clj or limitation of tools.build.
This comes about because the tests are run in a separate process, so that none of the tools.build/tools.deps.alpha stuff is on the classpath when running your code under test.
tools.build has tasks that support building a java command and executing it, so you're going to be running a -main function -- either in your own code or clojure.main. The -X stuff is all built into a small exec.jar that is bundled into the Clojure CLI but is not available as a library anywhere. See https://clojure.atlassian.net/browse/TBUILD-6 for some discussion around this (and code close to what we do at work to allow for "exec" task execution in our build.clj file -- it's pretty nasty and relies on internals of the Clojure CLI to work, since it has to generate a -X-style command-line from a data structure so that it can start the process off via the java command!).
If you execute tests in-process -- as happens if you just use an alias to run Cognitect's test-runner directly -- you can just require, resolve, and directly call the "exec" function from your build.clj script. But when you run test-runner or Koacha etc, you are only adding the test runner's dependencies into the mix, not all of the tools.* stuff (which drags in a lot of libraries!).
After much though and slack discussions I'll deprecate / delete all aliases that can be done with tools.build instead.
Add a section to Practicalli Clojure to cover tools.build and any useful projects that support it.
Resolved by #61