This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-02
Channels
- # adventofcode (97)
- # announcements (11)
- # babashka (18)
- # beginners (34)
- # biff (5)
- # cljfx (5)
- # clojure-europe (4)
- # clojure-uk (2)
- # clojurescript (7)
- # community-development (2)
- # hyperfiddle (8)
- # introduce-yourself (1)
- # music (2)
- # off-topic (2)
- # polylith (3)
- # practicalli (1)
- # releases (1)
- # shadow-cljs (28)
- # squint (1)
Is it possible to use a babashka project as a dependency for a different project? My use-case is related to Advent of Code -- I keep separate repos for each year, but reuse the same bb script for bootstrapping each day solution and running it. So ideally I would have a separate project, say, advent-of-code
, and all other repos (`2023`, 2022
...) would just have it as a dependency (that would mean the bb script from the AoC repo would be the executable for all particular repos). Hope it makes some sense.
and then in another project you can write in bb.edn
:
{:deps {my/script {:local/root "/path/to/library"}}}
In my case the my_script.clj
is just a bb.edn
+ a template file. So I would have 2 local repos (for simplicity sake) -- ~/aoc
with bb.edn
providing all the tasks and template.txt
, and ~/aoc23
which will be populated with solutions for 2023. If I put {:deps {bb {:local/root "~/aoc"}}}
in ~/aoc23/deps.edn would that work?
(Actually will test it rn)
It's a very simple bb script: https://github.com/caseneuve/aoc2023 -- I'd like to extract bb.edn and template.txt and reuse it
This will work when you add an adjacent script to your bb.edn like this:
#!/usr/bin/env bb
(require '[babashka.tasks :as tasks])
(apply tasks/run (symbol (first *command-line-args)) (rest *command-line-args*))
If you then put this script on your path, you can call it from everywhere.
Tasks are usually only used for project-local tasks but this is a hack to make them more globally usefulRight! So in order to make it less hacky, I could think about rewriting the tasks into a script that would be a dependency. But then I'd need to write the tasks for each repo again, so it's not perfect.
you don't need to do everything via tasks, what you want is probably a command line interface that you can use across projects
Yeah, I'm just processing what you said and trying to get out of the tasks box :)
Is using git libraries supported as well? https://clojure.org/guides/deps_and_cli#_using_git_libraries