Fork me on GitHub
Jem McElwain16:04:34

does anyone have an example or suggestions for how to structure a "multi-module" project using ideally, i would like to have a single build.clj from a root directory that's able to build jars of sub-projects in a consistent way, but i'm running into lots of problems trying to get this to work. wondering if anyone has advice on best practices here.


Happy to try to help if you can provide more info about what you tried and what doesn't work. We have a monorepo and build over a dozen uberjars from it using a single build.clj at the root. Here's an excerpt from our uberjars task:

(doseq [p projects]
      (println "\nRunning: uber on" p)
      (let [project-dir (str "projects/" p)
            aliases     (with-dir (io/file project-dir) (get-project-aliases))]
        (binding [b/*project-root* project-dir]
          (bb/clean {})
          (bb/uber (assoc (:uberjar aliases)
                          :compile-opts {:direct-linking true})))))
b is and bb is my library but it's only a very thin wrapper around providing "sane" defaults.


Each projects/<foo> folder has its own deps.edn to specify the deps needed for the uberjar (mostly just :local/root to other parts of the monorepo) and there's an :uberjar alias containing data -- options -- for the uber task.

❤️ 1

(defn- get-project-aliases []
  (let [edn-fn (juxt :root-edn :project-edn)]
    (-> (t/find-edn-maps)
is the t.d.a-based helper for getting aliases out of the project's deps.edn file.


(our monorepo is slowly migrating from an ad hoc approach to using Polylith which has helped a lot with separating out "build" concerns from dev/runtime concerns)

Adam Helins07:04:40

@U02AEH4M8GY I wrote a little helper for exactly that kind of setup and used it successfully in several projects. Just have to properly document it though 😅 I'm curious, what have you tried?

Jem McElwain23:04:26

Major problem was just that we were using 7.5.0, most things were fixed just by just upgrading to the latest version and using some of the provided build.clj as reference. Also had some issues with b/write pom skipping local deps, but realized that could be solved by providing extra deps.edn when creating basis.

Alex Miller (Clojure team)16:04:56

should be fine, just need to be careful with calling b/set-project-root! in each per-project context

Alex Miller (Clojure team)16:04:19

there's been at least one thread about this in #tools-build