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.

@Deprecated
@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.

Answer

Following @khmarbaise suggestion (thanks!) I’ve used archunit.org 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 {

    @ArchTest
    public static final ArchRule persistenceIdAnnotationRule = fields().that()
        .areDeclaredInClassesThat().areAnnotatedWith(Entity.class).and()
        .areAnnotatedWith(OneToOne.class).or()
        .areAnnotatedWith(OneToMany.class).or()
        .areAnnotatedWith(ManyToOne.class).or()
        .areAnnotatedWith(ManyToMany.class)
        .should(beAnnotatedForMyCustomAdapter());

    private static ArchCondition<? super JavaField> beAnnotatedForMyCustomAdapter() {
        return new ArchCondition<JavaField>("annotated with @JsonAdapter(MyCustomAdapter.class)") {
            @Override
            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));
            }
        };
    }

}