This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-11
Channels
- # adventofcode (42)
- # asami (13)
- # babashka (40)
- # beginners (25)
- # calva (39)
- # cider (18)
- # circleci (6)
- # cljs-dev (3)
- # clojure (39)
- # clojure-europe (16)
- # clojure-norway (9)
- # clojure-uk (2)
- # clojurescript (42)
- # datalevin (4)
- # datomic (23)
- # fulcro (33)
- # jobs (1)
- # malli (26)
- # minecraft (1)
- # off-topic (88)
- # pedestal (3)
- # polylith (8)
- # re-frame (6)
- # remote-jobs (2)
- # shadow-cljs (20)
- # tools-deps (12)
- # xtdb (5)
I try to override the maven root directory:
# ~/.polylith/config.edn
{:color-mode "dark"
:m2-dir "/Users/endymion/kaboom"
}
And poly sees this:
poly ws get:settings:m2-dir
"/Users/endymion/kaboom"
However when I run the unit tests poly still downloads files to the ~/.m2 directory
poly test since:previous-release
This will download to ~/.m2 and not to the /Users/endymion/kaboom
Is there something I do wrong?The poly
tool doesn’t configure Maven itself. This is only a way to tell it where the Maven root directory lives (and is used by the libs
command). So if it lives somewhere else than ~/.m2
or if you need to hard code a path (this was the reason it was introduced in the first place) then you can configure it in the ~/.polylich/config.edn
file.
Does this mean that :m2-dir
is not used by the test
command? How can I make the test
command use a custom maven root dir?
The test
command uses tools.deps
so if you want to move ~/.m2
somewhere else, you have to tell tools.deps
where it lives (I don’t know how to do that, or if it’s possible).
Symlinks work for my use case so np for me anymore. I digged into toe polylith code and found https://github.com/polyfy/polylith/blob/436d80d6a504d5f87d679da775a48e8101c8a3ec/components/deps/src/polylith/clj/core/deps/lib_deps.clj#L37
(defn ->config
"Converts back to the tools.deps format.
Tools.deps only resolves src depenencies (:deps) but not test
dependencies (:aliases > :test > :extra-deps) which is the reason
we merge :src and :test."
[{:keys [lib-deps maven-repos]}]
{:mvn/repos maven-repos
:deps (into {} (map key-as-symbol (merge (:src lib-deps)
(:test lib-deps))))})
(defn resolve-deps [project is-verbose]
"Resolves which library versions that are used by the given project."
(let [config (->config project)
_ (when is-verbose (println (str "# config:\n" config) "\n"))]
(tools-deps/resolve-deps config {})))
Which basically calls tools-deps/resolve-deps with a custom constructed config that does not include a :mvn/local-repo
. When I hardcode :mvn/local-repo "/Users/endymion/my-m2
stuff gets downloaded to my folder.Okay, well spotted! If you want, you can create an issue and I will have a look at it.
I’ve fixed the problem and merged it to https://github.com/polyfy/polylith/commit/8cd415f0da54e28f117c74848c32f91d23c805d4. Even though you have solved it already, it would be great if you could test it 🙂.