Is there a Maven plugin for checking annotations presence in code?

I need to ensure that, in specific classes (e.g. all classes extending some other class), fields annotated with e.g. @Deprecated are also annotated with @ThisOtherAnnotationMustBeHere.

@ThisOtherAnnotationMustBeHere // this must be present if @Deprecated is also present; otherwise build should fail
private String field;

I need in general something to check for the presence of annotations.
I guess I could write a JUnit test for this using reflection, but I was wondering if there was a Maven solution to this.


Following @khmarbaise suggestion (thanks!) I’ve used to write a unit test for this. In my case I needed to verify that join fields in JPA entities were annotated with a specific custom JsonAdapter

class CodeChecksTest {

    public static final ArchRule persistenceIdAnnotationRule = fields().that()

    private static ArchCondition<? super JavaField> beAnnotatedForMyCustomAdapter() {
        return new ArchCondition<JavaField>("annotated with @JsonAdapter(MyCustomAdapter.class)") {
            public void check(JavaField item, ConditionEvents events) {
                final Optional<JsonAdapter> annotation = item.tryGetAnnotationOfType(JsonAdapter.class);
                final boolean satisfied = annotation.isPresent() && annotation.get().value() == MyCustomAdapter.class;
                // createMessage is a utility method
                String message = createMessage(item,
                    (satisfied ? "is " : "is not ") + getDescription());
                events.add(new SimpleConditionEvent(item, satisfied, message));