Domain Driven Architecture

Mulitmodule Build in Clojure

Autor: Michael Jerger
July 14, 2016

Tags: opensource, clojure, build, pallet

When using clojure & lein for larger systems composed of many modules, you may know the multibuild problem - it's ugly and boring to release / test / ancient all your modules one after another manually! And it has to be done ordered by dependency!

On the other hand, you may insist on having multiple modules, because it's handy to have independent release cycles or different access policies.

Thats exactly our situation at dda-pallet (a clojure dev-ops-system we maintain).

Fortunately, there are some ways to solve this situation in lein:

We have a controlled development environment (our ide ist set up by dda-pallet - all repos are cloned to a well defined place) so we decided to give sub a try. Our git repository layout on disk looks like this:

  • ~/code/pallet/
    • dda-backup-crate/
    • dda-basic-crate/
    • ...
    • dda-pallet/
    • dda-pallet-masterbuild/

The masterbuilds project.clj now looks like:

(defproject org.domaindrivenarchitecture/dda-pallet-masterbuild "0.1.0-SNAPSHOT"
  ...
  :sub ["../dda-pallet"
        ...
        "../dda-backup-crate"]
  :plugins [[lein-sub "0.3.0"]]
  ...

Details at: https://github.com/DomainDrivenArchitecture/dda-pallet-masterbuild/blob/master/project.clj

And the dependent project looks like:

(defproject org.domaindrivenarchitecture/dda-pallet "0.1.0-SNAPSHOT"
  ...
  :profiles {:dev
             {:plugins
              [[lein-sub "0.3.0"]]}
            }}
  ...

Details at: https://github.com/DomainDrivenArchitecture/dda-pallet/blob/master/project.clj

Now we can do things like

lein sub ancient upgrade :interactive :allow-all

this will result in testing all projects for ancient dependencies ...

That's quite cool ... isn't it?

 

meissa GmbH

 

Recent Posts

 

 

We support