Fork me on GitHub
#polylith
<
2021-12-11
>
zetafish23:12:14

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?

tengstrand05:12:25

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.

zetafish10:12:10

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?

zetafish09:12:42

I guess I work around it by symlinking

tengstrand14:12:37

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).

zetafish11:12:14

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.

tengstrand12:12:33

Okay, well spotted! If you want, you can create an issue and I will have a look at it.

tengstrand07:12:12

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 🙂.