Commit Graph

94 Commits

Author SHA1 Message Date
Oliver Drotbohm
4218dffc9d GH-936 - Detect methods (meta-)annotated with @MessageMapping as module entry points.
We now consider all methods that are (meta-)annotated with Spring Messaging's @MessageMapping which is consistently used in a lot of broker annotations such as @(Rabbit|Kafka)Listener etc.
2024-11-19 23:01:29 +01:00
Oliver Drotbohm
169cf67128 Generally ignore generated code (annotated with @….Generated). 2024-11-05 16:16:07 +01:00
Oliver Drotbohm
34ce0add03 GH-919 - Add @CheckReturnValue and use it in Scenario API. 2024-10-29 22:15:12 +01:00
Oliver Drotbohm
6da5d1dafb GH-874 - Add LICENSE and NOTICE files to binaries. 2024-10-14 22:14:51 +02:00
Oliver Drotbohm
413e2f50b6 GH-846 - Fix module identifier lookup for jMolecules @Module(id = …).
We now properly translate jMolecules' @Module declaration configuring the id attribute explicitly into the identifier used for an application module.

Introduce @ApplicationModule(id = …) for Spring Modulith-native identifier customization.
2024-10-13 19:42:43 +02:00
Oliver Drotbohm
68185a7aef GH-872 - Introduce proper identifiers for ApplicationModules.
Introduced ApplicationModuleIdentifier that ensures that identifiers chosen for application modules do not contain a double colon (::) as we need those as separator characters for manual dependency declarations referring to named interfaces.
2024-10-13 19:41:49 +02:00
Oliver Drotbohm
e3077a7abd GH-862 - Trigger jMolecules architecture verifications if present on the classpath. 2024-10-08 11:14:06 +02:00
Oliver Drotbohm
438f17b56d GH-813 - Introduce FormattableType.
As replacement for misspelled Formatable type.
2024-09-20 22:02:17 +02:00
Oliver Drotbohm
dc74b414f3 GH-801 - Properly guard for presence of jMolecules' @Module type.
As @Module is absent from the Kotlin flavor of jMolecules, code that refers to that is now guarded with a more specific check for that type in particular.
2024-09-12 16:57:44 +02:00
Oliver Drotbohm
0bbda9a8bd GH-802 - Fix Javadoc. 2024-09-08 15:23:10 +02:00
Oliver Drotbohm
f09f3aa827 GH-802 - Allow transitive application module dependency resolution.
ApplicationModule now exposes both getDirectDependencies(…) and getAllDependencies(…), the former as alias for the now deprecated getDependencies(…) for symmetry reasons. The latter recursively resolves transitive dependencies.

We now optimize the dependency analysis by skipping types residing java and javax packages as they're not relevant to our dependency arrangement model. A few additional optimizations in ApplicationModuleDependencies to avoid iterating over each establishing dependency if all we need to look at is the general module dependency arrangement.

Improve performance of ApplicationModule.contains(…) checks by checking whether the given type can even live inside the package space of the module.
2024-09-06 21:41:35 +02:00
Oliver Drotbohm
636b5988cb GH-797 - Guard against multiple non-unique module base packages. 2024-09-04 10:34:10 +02:00
Oliver Drotbohm
1062f53bfa GH-613 - Add SPI to support external ApplicationModuleSource contributions.
We now expose ApplicationModuleSourceFactory as Spring Factories-based SPI interface to further contribute ApplicationModuleSource instances either from a provided root package subject for module detection through a (potentially customized) ApplicationModuleDetectionStrategy or by explicitly listing particular module base packages.
2024-09-04 08:51:19 +02:00
Oliver Drotbohm
b370d5a3f2 GH-787 - Allow references between sibling sub-modules.
Previously, we rejected references between sub-modules both contained in the same parent package.

Related ticket: GH-578.
2024-08-30 18:22:02 +02:00
Oliver Drotbohm
7838204c25 GH-578 - Support for nested application modules.
The ApplicationModules bootstrap now triggers the module base package detection, followed by a new, additional pass of detecting nested application module packages. Those packages are now added to the ones we create ApplicationModule instances for and also handed into the module instance creation step as exclusions to make sure that parent modules do not include code residing in sub-modules.

The bootstrap of ApplicationModules now uses a dedicated ApplicationModuleSource to allow calculating a default module name relative to the application base package.

Each module now operates on the Classes instance obtained from the JavaPackage instance that constitutes the module's base package but filtered by the given exclusions.
2024-08-16 17:09:51 +02:00
Oliver Drotbohm
b927bf1211 GH-764 - Prevent ApplicationModuleInformation from picking up info from nested packages. 2024-08-13 22:01:01 +02:00
Oliver Drotbohm
ff6f09606b GH-761 - Open up ApplicationModules.of(…) to take a DescribedPredicate<? super JavaClass>. 2024-08-13 16:26:47 +02:00
Oliver Drotbohm
849cc3e506 GH-745 - Polishing.
Reintroduce original method in deprecated form.
2024-07-29 23:58:29 +02:00
Igor Mukhin
cc571baf86 GH-745 - Fix typo in ApplicationModuleDetectionSTrategy.explicitlyAnnotated(). 2024-07-29 23:58:06 +02:00
Oliver Drotbohm
1b1028f059 GH-650 - Fix named interface detection in case of nested packages.
If named interfaces are declared in nested packages, the name detection might accidentally pick up the names declared in child packages. We now deliberately only inspect the base package.
2024-06-18 13:57:50 +02:00
Oliver Drotbohm
60149ea323 GH-660 - Dependency checks now explicitly skip module-internal dependencies.
As we process a type's entire type hierarchy for dependencies we might discover a foreign module's internal dependencies for modules that declare allowed dependencies explicitly. Explicitly declared dependencies so far solely verified the target being explicitly listed, which, for internal dependencies does not make sense. We now immediately start checking the source and target modules to be equivalent, in which case we can skip any further processing.
2024-06-18 12:29:04 +02:00
Oliver Drotbohm
7547bc2cad GH-652 - Polishing. 2024-06-06 16:23:58 +02:00
Oliver Drotbohm
ed1cb3fc91 GH-652 - Allow to configure the ApplicationModuleDetectionStrategy via a configuration property.
We now expose a configuration property spring.modulith.detection-strategy that can take either of the two prepared values "direct-sub-packages" (default) or "explicitly-annotated", or a fully qualified class name of the strategy to use.

Removed ApplicationModuleStrategies enum to avoid exposing the enum values as additional implementations. Those are now held as inline lambda expression in the factory methods on ApplicationModuleStrategy. Extracted the lookup of the strategy to use into ApplicationModuleDetectionStrategyLookup for easier testability.
2024-06-06 15:45:57 +02:00
Oliver Drotbohm
cffb0a242d GH-587 - Re-establish proper ApplicationModules instance caching.
The previous change unfortunately altered the CacheKey type in a way that it does not result in equal instances for the same set of parameters, primarily because SingletonSupplier does not implement equals(…)/hashCode(). We now resort to include the ModulithMetadata source in the equals(…) / hashCode() calculation rather than the ModulithMetadata instance itself. This also avoids annotation processing during CacheKey instance creation.
2024-05-23 00:23:02 +02:00
Oliver Drotbohm
21bd2cef75 GH-587 - ModulithMetadata now exposes all base packages.
Previously, we had a variety of places calculating the overall packages to inspect for types. This is now all consolidated into the ModulithMetadata abstraction exposing them directly.
2024-05-20 19:58:30 +02:00
Oliver Drotbohm
04c1203f65 GH-587 - Additional modulith packages are now considered for application classes. 2024-05-20 19:57:23 +02:00
Oliver Drotbohm
51c5f0bf42 GH-601 - Support for wildcard references to named interfaces in explicitly defined allowed application module dependencies.
When defining allowed application module dependencies to named interfaces, the asterisk can now be used to allow referencing all named interfaces declared by the target module.
2024-05-16 16:03:14 +02:00
Oliver Drotbohm
e9203ca159 GH-594 - Polishing. 2024-05-16 13:27:45 +02:00
Oliver Drotbohm
3855479c7c GH-595 - Invalid dependency into named interface now gets reported properly. 2024-05-16 12:34:28 +02:00
Oliver Drotbohm
2bf9f797ec GH-594 - Deduplicate violations with the same message.
Moving away from exceptions as carriers for violations.
2024-05-16 12:20:44 +02:00
Oliver Drotbohm
ce2f608e60 GH-536 - Add missing package-info.java files. 2024-03-22 08:48:51 +01:00
Oliver Drotbohm
e41d7ec083 GH-520 - Early reject invalid ApplicationModules bootstraps.
We now immediately reject the ApplicationModules bootstrap in case the initial scanning of the root packages yield no classes at all.
2024-03-05 19:34:47 +01:00
Oliver Drotbohm
c45a0fc9b7 GH-522 - Polishing. 2024-03-05 11:52:04 +01:00
Oliver Drotbohm
5f7e6a2479 GH-522 - Support for package info types.
Introduce @PackageInfo annotation to allow marking a types as alternative to Java's native package-info.java so that annotation lookups on a JavaPackage will also find annotations placed on that type. Useful to declare package scoped metadata like @ApplicationModule and @NamedInterface for languages that do not support packages well enough (read: Kotlin).
2024-03-05 09:55:34 +01:00
Oliver Drotbohm
f3c111f769 GH-284 - Support for open application modules.
Application modules can now be declared as open, which causes internal components being exposed for access by other modules.
2024-02-29 12:58:49 +01:00
Lukas Dohmen
d325c83736 GH-508 - Fix parameter name to match Javadoc. 2024-02-23 11:44:52 +01:00
josroseboom
e1e9b237c8 GH-490 - Use Types constant to decide if a type is an entity. 2024-02-14 16:36:15 +01:00
Oliver Drotbohm
c32227bdfb GH-463 - Update copyright headers. 2024-01-17 19:45:40 +01:00
Oliver Drotbohm
48aa0b246a GH-406 - Improve detection of AOT types generated by Spring.
We now guard the annotation predicate for @Generated behind a classpath check to avoid a NoClassDefFoundError on previous versions of Spring Framework.
2024-01-17 16:30:40 +01:00
Oliver Drotbohm
b9f3fc2263 GH-418 - Include JSR 303 ConstraintValidator implementations in bootstrap dependency analysis.
Spring Boot configures Hibernate Validator in a way that the latter looks up the components it needs to instantiate via the Spring container. That in turn then creates prototype instances of the types requested. This means, implementations of e.g. ConstraintValidator do not need to be explicitly marked as Spring beans, but could still declare dependencies to other Spring beans. If such a dependency crosses a module boundary, we currently fail to detect that implicitly established module dependency.

This is now fixed by considering ConstraintValidator implementations Spring beans implicitly in out bootstrap dependency analysis.
2023-12-21 18:09:29 +01:00
Oliver Drotbohm
c1f5630a72 GH-406 - Improving the detection of Spring AOT classes.
We now inspect the classes for the newly introduced Spring AOT @Generated annotation instead of a name containing a double underscore.
2023-12-08 22:15:29 +01:00
Oliver Drotbohm
e7b531e061 GH-406 - Ignore Spring AOT generated types in architecture model.
We now explicitly exclude classes generated by Spring AOT in the architectural model. For technical reasons, they might introduce dependencies to application components considered module internals otherwise. Also, proxies generated do not need to be considered either.
2023-12-06 14:17:43 +01:00
Oliver Drotbohm
889c849492 GH-348 - Avoid eager reference to runtime artifact from core starter.
Removed the inclusion of the spring-modulith-runtime artifact from the …-starter-core one to avoid issues in native images in a Spring Modulith default setup. As the artifact is still needed to support ApplicationModuleInitializer implementations, we now explicitly check for the presence of those and verify the artifact is actually available and hint the user at explicitly adding it if missing.
2023-10-27 09:41:26 +02:00
Oliver Drotbohm
86f745e5b7 GH-317 - Fix Javadoc. 2023-10-16 08:28:16 +02:00
Oliver Drotbohm
9148a57b02 GH-317 - Detect violations from types located in root packages.
We now create artificial root application modules for all root packages to detect violations (for example, types located in root packages referring to module-internal types).
2023-10-16 07:57:16 +02:00
Oliver Drotbohm
4a857dcddf GH-323 - Move off of Google's Suppliers.memoize(…). 2023-10-15 19:23:08 +02:00
Oliver Drotbohm
cb6d71ba60 GH-319 - Fix ApplicationModule by package name lookup.
Prior to this commit, the lookup for an ApplicationModule would find modules solely depending on the reference string starting with the base package. That means that a module with base package com.acme.foo, a request for com.acme.foobar would've resulted in a positive match, which of course is wrong.

We now match against either the module's base package or against the reference starting with the base package followed by a dot.
2023-10-15 17:29:27 +02:00
Oliver Drotbohm
9568f29613 GH-267 - Explicitly declared empty allowed dependencies now forbids any dependency.
The default for @ApplicationModule(allowedDependencies) is now a single element list with a dedicated token we recognize as "all dependencies allowed". This allows users to declare an empty array explicitly to disallow any outgoing dependencies for an application module. Previously, such a declaration would have allowed any dependency.
2023-08-15 19:52:02 +02:00
Oliver Drotbohm
43418b5fe0 GH-246 - Upgrade to ArchUnit 1.1.0.
Related tickets: GH-221.
2023-08-09 21:21:18 +02:00
Oliver Drotbohm
9fe114387a GH-221 - Temporarily shadow ArchUnit's Location type.
It includes the fix submitted for TNG/ArchUnit#1131. To be removed once we can upgrade to a released version of the fix.
2023-07-20 16:26:32 +02:00