GH-36 - Better dependency verification for named interfaces.
We now verify detected dependencies against optionally explicitly defined ones. Those can refer to named interfaces (via the "moduleName :: namedInterfaceName" syntax). If such an allowed dependency is defined, all dependencies towards other named interfaces (also the unnamed one) are rejected. Some Javadoc polishing.
This commit is contained in:
@@ -22,20 +22,29 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation to customize information of a {@link Modulith} module.
|
||||
*
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
@Target({ ElementType.PACKAGE, ElementType.ANNOTATION_TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApplicationModule {
|
||||
|
||||
/**
|
||||
* The human readable name of the module to be used for display and documentation purposes.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String displayName() default "";
|
||||
|
||||
/**
|
||||
* List the names of modules that the module is allowed to depend on. Shared modules defined in {@link Modulith} will
|
||||
* be allowed, too.
|
||||
*
|
||||
* be allowed, too. Names listed are local ones, unless the application has configured
|
||||
* {@link Modulithic#useFullyQualifiedModuleNames()} to {@literal true}. Explicit references to
|
||||
* {@link NamedInterface}s need to be separated by a double colon {@code ::}, e.g. {@code module::API} if
|
||||
* {@code module} is the logical module name and {@code API} is the name of the named interface.
|
||||
*
|
||||
* @return
|
||||
* @see NamedInterface
|
||||
*/
|
||||
String[] allowedDependencies() default {};
|
||||
}
|
||||
|
||||
@@ -21,8 +21,11 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Annotation to mark a package as named interface of a {@link ApplicationModule} (either implicit or explicitly annotated).
|
||||
* Annotation to mark a package as named interface of a {@link ApplicationModule} (either implicit or explicitly
|
||||
* annotated).
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
@@ -32,9 +35,20 @@ import java.lang.annotation.Target;
|
||||
public @interface NamedInterface {
|
||||
|
||||
/**
|
||||
* The name of the interface.
|
||||
* The name(s) of the named interface. Declaring multiple values here is useful in case named interfaces are defined
|
||||
* based on types and a particular type is supposed to be part of multiple named interfaces.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String[] value();
|
||||
@AliasFor("name")
|
||||
String[] value() default {};
|
||||
|
||||
/**
|
||||
* The name(s) of the named interface. Declaring multiple values here is useful in case named interfaces are defined
|
||||
* based on types and a particular type is supposed to be part of multiple named interfaces.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@AliasFor("value")
|
||||
String[] name() default {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user