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
Provide a way to use a different module recognition strategy #137
Comments
We now allow the customization of which packages are considered module base packages via the ModuleDetectionStrategy interface. Default implementations are exposed as factory methods on the interface itself. Custom implementations can be registered via an entry for org.moduliths.model.ModuleDetectionStrategy in a META-INF/spring.factories file on the classpath.
There's now a class CustomModuleDetectionStrategy implements ModuleDetectionStrategy {
private final ModuleDetectionStrategy delegate = ModuleDetectionStrategy.directSubPackage();
/*
* (non-Javadoc)
* @see org.moduliths.model.ModuleDetectionStrategy#getModuleBasePackages(org.moduliths.model.JavaPackage)
*/
@Override
public Stream<JavaPackage> getModuleBasePackages(JavaPackage basePackage) {
return delegate.getModuleBasePackages(basePackage).filter(it -> {
return it.getDirectSubPackages().stream()
.map(JavaPackage::getLocalName)
.anyMatch("impl"::equals);
});
}
} |
We now allow the customization of which packages are considered module base packages via the ModuleDetectionStrategy interface. Default implementations are exposed as factory methods on the interface itself. Custom implementations can be registered via an entry for org.moduliths.model.ModuleDetectionStrategy in a META-INF/spring.factories file on the classpath.
We now allow the customization of which packages are considered module base packages via the ModuleDetectionStrategy interface. Default implementations are exposed as factory methods on the interface itself. Custom implementations can be registered via an entry for org.moduliths.model.ModuleDetectionStrategy in a META-INF/spring.factories file on the classpath.
Thanks, I will try it. |
Last deployed 1.1.0-SNAPSHOT at https://repo.spring.io/libs-snapshot/ is from 13-Nov-2020 16:25. Is this intended? |
The switch to |
Today I tried to apply Moduliths (especially it's documentation facilities) to our package structure. Moduliths assumes that the modules are direct sub-packages of a base package. This assumption most often applies to our package structure, but there are some cases which do not fit that well.
{modulepackage}.api
– Public API of the module{modulepackage}.impl
– Internals which cannot be referenced from other modulesWe can compose applications by adding impl-Modules to the runtime classpath which means that the module exists in an application if the
{modulepackage}.impl
is present at runtime. The existence of{modulepackage}.api
is irrelevant if the correspondingimpl
-package is not available. Currently Moduliths identifies the module just because of the existence of{modulepackage}.api
.Generally speaking it would be great to have some kind of module recognition strategy which can be altered by a SPI. By default you could use a sub-package-based strategy, but I would like to implement a strategy which reflects our conventions how a module is structured and identified.
The idea is similar to the
ArchitecturallyEvidentType
concept which is used to provide different strategies how to identify Aggregate roots, entities or services.The text was updated successfully, but these errors were encountered: