Fork me on GitHub
#polylith
<
2021-11-06
>
Matt Ielusic06:11:51

How do people handle project configuration? Some of the projects I'm migrating use the same set of configuration keys, but with different values. I can't have multiple sets of configuration files loaded at once.

furkan3ayraktar13:11:15

I don’t understand fully. Can you be more specific about how do you store and load your configuration?

Matt Ielusic06:11:05

Each service has its own repo and stores config as an EDN file. Lots of the configuration is for shared code. As-is, if I try to load the config for two projects at once I'll end up with conflicts like:

project1.edn:
{shared/foo "bar"}

project2.edn:
{shared/foo "baz"}

furkan3ayraktar06:11:04

Ya can place those config files under each project’s resources directory and include it as a path in projects deps.edn. In your development project, you can have one configuration that you want to load when you start your REPL. This way, you’ll not have conflicts and you’ll get what you need on tour REPL.

pez11:11:11

To have a bit less of duplication of dependencies, I am now testing to have local dependencies on projects and bases in the top level :dev alias. And then each project specifies its dependencies, wether it is from maven or from local components, even clojure itself. It seems to work. The :dev alias looks something like so:

{:dev
  {:extra-paths ["development/src"]
   :extra-deps {;; awesome-system
                awesome-system/awesome-project-a {:local/root "projects/awesome-project-a"}
                awesome-system/awesome-project-b {:local/root "projects/awesome-project-b"}

                ;; dev facilities
                org.clojure/tools.deps.alpha {:mvn/version "0.12.1067"}
                com.lambdaisland/classpath {:mvn/version "0.0.27"}}}
Anyone see a reason why I should not do it this way?

furkan3ayraktar13:11:11

There are two that comes to my mind right away: 1) there might be different implementations of interfaces in the projects and development project will include them and you won’t know which one is loaded to REPL 2) poly tool cannot understand the development project anymore This does not apply to you :) but this setup won’t work with Cursive.

furkan3ayraktar13:11:43

Also, you shouldn’t see the development project’s deps.edn as duplication, it is just another project, with its own set of components, bases, and libraries. You are configuring it according to your local needs, rather than the deployment needs.

💯 1
1
furkan3ayraktar13:11:47

I really like to be verbose. I like the fact that poly cli does not add components/bases to any project when they are created. I pick where to add them, whether it be the development project or any other project. Most of the time, we create a component and it only lives in the development project until its ready to be included in one or more other projects and get deployed.

pez13:11:19

Awesome, thanks! I’ll go back to dupli… I mean being verbose. 😃

seancorfield18:11:47

"Most of the time, we create a component and it only lives in the development project until its ready to be included in one or more other projects and get deployed." - yup, that's how we do things too.

polylith 1
pez13:11:47

I want to be able to load dependencies from the REPL. What’s the ways people achieve that? lambdaisland/classpath doesn’t do transitives yet. I’m going with tools.deps add-lib now, and think I might find a workflow I like.

pez13:11:37

Yeah, I thinkI like the add-libs way.

"calva.customREPLCommandSnippets": [
        ...
        {
            "key": "a",
            "name": "Add selected dependency",
            "snippet": "(require '[clojure.tools.deps.alpha.repl :refer [add-libs]])\\n(add-libs '{$selection})"
        },
        ...
    ],
Then when I add a dependency to some deps.edn, I just select it and hit ctrl+alt+space a.

furkan3ayraktar15:11:44

I was adding add-libs dependency to my development projects dependencies and running it from my dev namespace but this is way better!

seancorfield18:11:11

I have this in my Clover setup. ctrl-; ctrl- shift-a bound to similar code.

polylith 1