Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for modular projects #23

Open
fabiodomingues opened this issue Sep 21, 2022 · 1 comment
Open

Support for modular projects #23

fabiodomingues opened this issue Sep 21, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@fabiodomingues
Copy link
Owner

To support for modular projects I thought of creating a modules key in the root of the config as today we already have layers.

Something like modules sharing a common layer definition:

{:modules {:module-a {:defined-by "module-a\..*"}
           :module-b {:defined-by "module-b\..*"}}
 :layers {:controller        {:defined-by         ".*\\.controllers?\\..*"
                              :accessed-by-layers #{}}
          :logic             {:defined-by         ".*\\.logic\\..*"
                              :accessed-by-layers #{:controller}}
          :model             {:defined-by         ".*\\.models?\\..*"
                              :accessed-by-layers #{:logic :controller}}}}

And that would be a bit dynamic, as it would also support the possibility of having a common layer definition and a module with its own layer definition:

{:modules {:module-a {:defined-by "module-a\..*"
                      :layers {:layer        {:defined-by         ".*\\.controllers?\\..*"
                                              :accessed-by-layers #{}}
                               :logic             {:defined-by         ".*\\.logic\\..*"
                                                   :accessed-by-layers #{:controller}}
                               :model             {:defined-by         ".*\\.models?\\..*"
                                                   :accessed-by-layers #{:logic :controller}}}}
           :module-b {:defined-by "module-b\..*"}}
 :layers {:controller        {:defined-by         ".*\\.controllers?\\..*"
                              :accessed-by-layers #{}}
          :logic             {:defined-by         ".*\\.logic\\..*"
                              :accessed-by-layers #{:controller}}
          :model             {:defined-by         ".*\\.models?\\..*"
                              :accessed-by-layers #{:logic :controller}}}}

Or even each module having its own layer definition:

{:modules {:module-a {:defined-by "module-a\..*"
                      :layers {:controller        {:defined-by         ".*\\.controllers?\\..*"
                                                   :accessed-by-layers #{}}
                               :logic             {:defined-by         ".*\\.logic\\..*"
                                                   :accessed-by-layers #{:controller}}
                               :model             {:defined-by         ".*\\.models?\\..*"
                                                   :accessed-by-layers #{:logic :controller}}}}
           :module-b {:defined-by "module-b\..*"
                      :layers {:controller        {:defined-by         ".*\\.controllers?\\..*"
                                                   :accessed-by-layers #{}}
                               :logic             {:defined-by         ".*\\.logic\\..*"
                                                   :accessed-by-layers #{:controller}}
                               :model             {:defined-by         ".*\\.models?\\..*"
                                                   :accessed-by-layers #{:logic :controller}}}}}}

For each namespace the clj-depend analyzer would check if the namespace belongs to any of the modules. If the identified module has a layer definition it will be used, otherwise the common layer definition will be used.

If there is no modules key declared the behavior will be the same as today.

@fabiodomingues fabiodomingues added the enhancement New feature or request label Sep 21, 2022
@vitorfariaz
Copy link

If a rule of the module override a rule of common layers, what will be considered? A think today it already happens if we create 2 rules that override each other in common layers but i did not understand the current behavior tbh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants