TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.18k stars 288 forks source link

Enforce ArchTests when module is depended upon #1201

Closed lobaorn closed 9 months ago

lobaorn commented 9 months ago

Hey there, I am not sure if this is possible already, if so please just point me to the probable direction.

The question is, in a multi-module project, I wish now to create a common module that will do some orthogonal features, like observability.

If this Module is "M1", and I wish to enforce a convention of classes names, packages, inheritance, interfaces and everything of how "M1" is used in modules that include it as a dependency, how should I do it?

In a Maven context at least, I am not sure if it is possible right now, because the modules that depend on "M1" would just add it, maybe with test scope, but then will it run properly?

I will try it locally in the project, but my guess is that it won't be enough to do it how it is envisioned.

If it works as expected, I believe it will be a great use case to internal frameworks and to enforce conventions for new developers in many contexts (even in open source projects).

lobaorn commented 9 months ago

As it seems, this Maven Plugin (https://github.com/societe-generale/arch-unit-maven-plugin) can do basically what I was envisioning, differently way of doing so, but the result will be the same in my context. I will close the Issue now, but perhaps it will be useful for someone else with same use cases.