Skip to content

[Feature Request] Support meta-annotations for @AnalyzeClasses #1590

@jendrikoltmanns

Description

@jendrikoltmanns

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 {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions