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

Add mandatory dependency settings to layeredArchitecture() #892

Merged

Conversation

codecholeric
Copy link
Collaborator

Ever since layeredArchitecture() supports rules on "forward dependencies" (i.e. whereLayer(..).mayOnlyAccessLayers(..)) there has been confusion about how to exclude false positives like java.lang.Object. While excluding these dependencies can be achieved by ignoreDependency(..) this does not seem to be an API that is easily discoverable.

We now make it mandatory to choose how to treat dependencies right in the beginning. This way users will be guided to those considerations and be made aware of pitfalls as well as have an easy predefined option how to ignore false positives.

This will be a breaking change, since existing layeredArchitecture() definitions will not compile anymore without adding the choice of how to treat dependencies.

Resolves: #887

@codecholeric codecholeric added this to the 1.0.0 milestone Jun 18, 2022
@codecholeric codecholeric force-pushed the support-layered-architecture-dependency-exclusion-strategies branch from afa4c95 to aea00a1 Compare June 18, 2022 15:35
@codecholeric codecholeric force-pushed the support-layered-architecture-dependency-exclusion-strategies branch from aea00a1 to 5b6d4bc Compare June 19, 2022 14:17
@kaebiscs
Copy link

Looks good to me. No remarks.

The tests for onion architecture and layered architecture are quite unrelated except for some common test infrastructure. In the end these are two classes housed inside the same umbrella class, but that does not mean we have to test them in one single test class. Having a single test class makes it harder to understand which test method belongs to which class.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
In particular, since adding the possibility to define forward rules within the layered architecture (e.g. `whereLayer(..).mayOnlyAccessLayers(..)`) there has been quite some confusions about how to deal with false positives, like dependencies to `java.lang.Object`. While it is generally easy to exclude those via `.ignoreDependency(..)` this does not seem to be very intuitive for users as there have been multiple GitHub issues about how to deal with those dependencies.
We now "force" users to make a (well-documented) decision how to deal with dependencies right when defining the layered architecture. The three predefined choices should cover the vast majority of user use cases (similar to `PlantUmlArchCondition`). For special cases where these options do not suffice it is always possible to simply pick `consideringAllDependencies()` and do fine grained `ignoreDependency(..)` calls later on.

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
@codecholeric codecholeric force-pushed the support-layered-architecture-dependency-exclusion-strategies branch from 5b6d4bc to 7529901 Compare June 22, 2022 11:53
@codecholeric codecholeric merged commit 69d4398 into main Jun 22, 2022
@codecholeric codecholeric deleted the support-layered-architecture-dependency-exclusion-strategies branch June 22, 2022 15:08
TomerFi added a commit to TomerFi/alexa-skill-shabbat-times that referenced this pull request Oct 7, 2022
TNG/ArchUnit#892
Signed-off-by: Tomer Figenblat <tomer.figenblat@gmail.com>
TomerFi added a commit to TomerFi/alexa-skill-shabbat-times that referenced this pull request Oct 7, 2022
…#652)

* build(deps-dev): bump archunit-junit5 from 0.23.1 to 1.0.0 in /lambda

Bumps [archunit-junit5](https://github.com/TNG/ArchUnit) from 0.23.1 to 1.0.0.
- [Release notes](https://github.com/TNG/ArchUnit/releases)
- [Commits](TNG/ArchUnit@v0.23.1...v1.0.0)

---
updated-dependencies:
- dependency-name: com.tngtech.archunit:archunit-junit5
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* test: fix failing test after dependency breaking change

TNG/ArchUnit#892
Signed-off-by: Tomer Figenblat <tomer.figenblat@gmail.com>

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Tomer Figenblat <tomer.figenblat@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tomer Figenblat <tomer.figenblat@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArchUnit: how can one silence references to arrays of basic types for method mayOnlyAccessLayers(...)?
2 participants