Problem
When writing multiple ArchUnit test classes, the @AnalyzeClasses configuration (packages, import options, etc.) is often repeated. This leads to duplication and makes it harder to enforce a consistent analysis scope across tests.
In larger projects, especially with modular or DDD-based structures, we would like to centralize this configuration and hide it behind a custom annotation.
Use Case
I would like to define a project-specific meta-annotation that encapsulates the @AnalyzeClasses setup once and reuse it across all ArchUnit tests. For example:
@target(ElementType.TYPE)
@retention(RetentionPolicy.RUNTIME)
@AnalyzeClasses(
packages = "com.mycompany",
importOptions = { ImportOption.DoNotIncludeTests.class }
)
public @interface ArchitectureTest {
}
Problem
When writing multiple ArchUnit test classes, the @AnalyzeClasses configuration (packages, import options, etc.) is often repeated. This leads to duplication and makes it harder to enforce a consistent analysis scope across tests.
In larger projects, especially with modular or DDD-based structures, we would like to centralize this configuration and hide it behind a custom annotation.
Use Case
I would like to define a project-specific meta-annotation that encapsulates the @AnalyzeClasses setup once and reuse it across all ArchUnit tests. For example:
@target(ElementType.TYPE)
@retention(RetentionPolicy.RUNTIME)
@AnalyzeClasses(
packages = "com.mycompany",
importOptions = { ImportOption.DoNotIncludeTests.class }
)
public @interface ArchitectureTest {
}