Skip to content

Commit 1dd7238

Browse files
AquaGenLiveodrotbohm
authored andcommitted
GH-550 - Add section on how to exclude packages from application module detection.
1 parent 769cefa commit 1dd7238

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/docs/antora/modules/ROOT/pages/verification.adoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,33 @@ If those are configured, dependencies to other application modules are rejected.
2929
See xref:fundamentals.adoc#modules.explicit-dependencies[Explicit Application Module Dependencies] and xref:fundamentals.adoc#modules.named-interfaces[Named Interfaces] for details.
3030

3131
Spring Modulith optionally integrates with the jMolecules ArchUnit library and, if present, automatically triggers its Domain-Driven Design verification rules described https://github.com/xmolecules/jmolecules-integrations/tree/main/jmolecules-archunit[here].
32+
33+
34+
[[excluding-packages]]
35+
== Excluding Packages
36+
37+
In case you like to exclude certain Java classes or full packages, you can do so with:
38+
39+
[tabs]
40+
======
41+
Java::
42+
+
43+
[source, java, role="primary"]
44+
----
45+
ApplicationModules.of(Application.class, JavaClass.Predicates.resideInAPackage("com.example.db")).verify();
46+
----
47+
Kotlin::
48+
+
49+
[source, kotlin, role="secondary"]
50+
----
51+
ApplicationModules.of(Application::class, JavaClass.Predicates.resideInAPackage("com.example.db")).verify()
52+
----
53+
======
54+
55+
Different examples of exclusions:
56+
57+
* `com.example.db` -- Matches all files in the given package `com.example.db`.
58+
* `com.example.db..` -- Matches all files in the given package (`com.example.db`) and all sub-packages (`com.example.db.a` or `com.example.db.b.c`).
59+
* `..example..` -- Matches 'a.example', 'a.example.b' or 'a.b.example.c.d', but not 'a.exam.b'
60+
61+
Full details about possible matchers can be found in the JavaDoc of PackageMatcher: https://github.com/TNG/ArchUnit/blob/main/archunit/src/main/java/com/tngtech/archunit/core/domain/PackageMatcher.java

0 commit comments

Comments
 (0)