lundi 19 février 2018

How to get class annotation from inside the maven-plugin

There is a main project which contains annotated classes like this:

@Attributes(title="GetClientDataRequest" ,description="...", additionalProperties = false)
public class GetClientDataRequest extends GetClientDataAbstract {...}

This annotation is from the jjschema library for json-schema generation:

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
public @interface Attributes { ... }

But some other classes may be not annotated. So I need to analyze it inside my custom maven plugin. But standart reflection methods doesn't work:

Class schema class = GetClientDataRequest.class

schemaClass.getAnnotation(Attributes.class); - returns null schemaClass.getAnnotations().length; - returns 0 schemaClass.isAnnotationPresent(Attributes.class); returns false

What is wrong?





Aucun commentaire:

Enregistrer un commentaire