Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate :project/jar and :project/uberjar aliases to tools.build #43

Closed
seancorfield opened this issue Feb 17, 2022 · 7 comments
Closed
Assignees

Comments

@seancorfield
Copy link

seancorfield commented Feb 17, 2022

Add a workable approach to using tools.build from Practicalli Clojure deps.edn, ideally without having to add any other files to a project (external dependency to using the alias)

Putting this on hold as tools.build seems more applicable to a project deps.edn than user config

References

Background

:project/jar and :project/uberjar aliases depend on depstar which was deprecated (and archived) for six months.

tools.build should be the preferred approach

@practicalli-johnny practicalli-johnny self-assigned this Feb 17, 2022
@practicalli-johnny
Copy link
Contributor

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.

@practicalli-johnny practicalli-johnny changed the title depstar is deprecated and archived; use tools.build Migrate :project/jar and :project/uberjar aliases to tools.build Feb 17, 2022
@seancorfield
Copy link
Author

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...

@seancorfield
Copy link
Author

@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.

@practicalli-johnny
Copy link
Contributor

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.

@seancorfield
Copy link
Author

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!).

@practicalli-johnny
Copy link
Contributor

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.

@practicalli-johnny
Copy link
Contributor

Resolved by #61

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

2 participants