The Polylith version of the my usermanager example app is “done” — incorporating the great feedback from Joakim as well as some additional refactoring: https://github.com/seancorfield/usermanager-example/tree/polylith (including an updated architecture image: poly info
+ poly libs
+ poly deps
— I figured out a relatively easy way to do this as a single partial screenshot 🙂 ). Note that the project tests do not pass yet due to a small bug in poly test
re: project test dependencies. I have a local copy of the Polylith repo with a fix that seems to make it work and Joakim will be looking at that soon.
Hi @seancorfield,
Please check out my latest changes in the issue-66 branch. I have fixed the issues we encountered. Do this:
• Use the latest SHA: 783916018b20a76f9054af8086e09e8f3335a3ae
• In components/schema-fixture/deps.edn
, add com.h2database/h2
.
• In projects/user-manager/deps.edn
fix one of the paths to “../../components/schema-fixture” + remove the library com.h2database/h2
(it will be picked up by the schema-fixture
component).
• Check that the libs
command looks like the screenshot.
When you run the libs
command, each project will now have two characters instead of one where the first one says whether the library is used by src
code library. The second character is set if the library is used by the tests
.
The documentation in the libs
section is also updated.
Okay, so are you considering converting it to a Polylith?
Splitting up the codebase the way you have, adds a lot of value. I remember that you explained that you have a 1:1 relationship between projects and “bases” (which are a merge of a base and a set of potential components). By going all the way, you could split these “bases” into “pure” bases with a set of components for each project, and get even smaller building blocks that could be shared across projects. Now when you have refactored the User Manager project, this would be the next natural step! 😃
Haha... it's unlikely. It's 112K lines of Clojure and it would be an enormous piece of work just to get the same system working 🙂 I will certainly bear it in mind as I do refactoring from here on: I'll gradually adopt a more uniform namespace approach, but I doubt we'll ever push our "components" down into the Polylith categories -- it's not worth the churn at this point.
Yeah, that’s a lot of code! 🙂
Like so?
(! 918)-> cat components/schema-fixture/deps.edn
{:paths ["src" "resources"]
:deps {com.github.seancorfield/next.jdbc {:mvn/version "1.1.646"}
com.stuartsierra/component {:mvn/version "1.0.0"}}
:aliases {:test {:extra-paths ["test"]
:extra-deps {com.h2database/h2 {:mvn/version "1.4.200"}}}}}
(! 919)-> cat projects/usermanager/deps.edn
{:paths ["src" "resources"]
:deps {poly/base-web {:local/root "../../bases/web"}
poly/app-state {:local/root "../../components/app-state"}
poly/database {:local/root "../../components/database"}
poly/department {:local/root "../../components/department"}
poly/schema {:local/root "../../components/schema"}
poly/user {:local/root "../../components/user"}
poly/web-server {:local/root "../../components/web-server"}
org.clojure/clojure {:mvn/version "1.10.3"}
;; specify DB driver for "production" usage:
org.xerial/sqlite-jdbc {:mvn/version "3.34.0"}}
:aliases {:test {:extra-paths ["test"]
:extra-deps {poly/schema-fixture {:local/root "components/schema-fixture"}
org.clojure/test.check {:mvn/version "1.1.0"}}}
:uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.0.211"}}
:exec-fn hf.depstar/uberjar
:exec-args {:jar "usermanager.jar"
:aot true
:main-class usermanager.web.main}}}}
I still get this error running the tests:
Couldn't resolve libraries for the usermanager project: java.lang.NullPointerException: Cannot invoke "java.io.File.isAbsolute()" because "f" is null
Cannot invoke "java.io.File.isAbsolute()" because "f" is null
I don’t get quite the same libs
output as you — poly/schema-fixture
shows up:
library version KB um dev e e t a e r r b
------------------------------------------------- -- --- ----------------------
com.github.seancorfield/next.jdbc 1.1.646 43 x- xx · x x x x x · ·
com.h2database/h2 1.4.200 2,249 -- -x · · · · · · · ·
com.stuartsierra/component 1.0.0 18 x- xx x x · · x · x x
compojure/compojure 1.6.2 14 x- xx · · · · · · · x
org.clojure/clojure 1.10.3 3,822 xx xx · · · · · · · ·
org.clojure/test.check 1.1.0 38 -x -x · · · · · · · ·
org.xerial/sqlite-jdbc 3.34.0 7,125 xx xx · · · · · · · ·
poly/schema-fixture 0 -x -- · · · · · · · ·
ring/ring 1.9.2 4 x- xx · · · · · · x x
ring/ring-defaults 0.3.2 7 x- xx · · · · · · · x
selmer/selmer 1.12.33 60 x- xx · · · · · · · x
@tengstrand I don’t see the change to local root project size that I mentioned?
That was the only change I needed locally in order to get this to work.
Ah, with only my small change, I needed the H2 driver in schema-fixture
:deps
, not :extra-deps
under :test
— which makes sense since it is a runtime (source) requirement for the fixture. It is not a test-only dependency for the fixture.
Looking on the issue-66
branch https://github.com/polyfy/polylith/blob/issue-66/components/lib/src/polylith/clj/core/lib/local_size.clj#L11 — that is still incorrect and will produce a corrupted local dep map because it omits :path
if there’s a size.
I updated the usermanager repo, just so you can verify the changes I made were correct. Here’s the commit: https://github.com/seancorfield/usermanager-example/commit/a7fdc513c243c054a86cb145818ae5789d11339f