I have a maven project and I want to create custom annotations to use in it.
I need that those annotations only be processed when some parameter is present, because I want to launch it a jenkins task.
How can I achieve it? Googling, I thought about creating a custom maven plugin for it, but I don't know how process the annotations in it.
This it is totally new for me and I would like your advice.
EDIT: I've tried creating a new maven plugin and with the reflections library find all classes with the annotation, but it isn't finding anything.
EDIT2: Following steps @Praveen Kumar, I was able to create a Custom Annotation Processor which process my method annotations. But I don't know how to execute the annotated method(I don't know either if this can be done)
@SupportedAnnotationTypes({"*"})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class MyProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement annotations, RoundEnvironment roundEnv) {
for(Element el : roundEnv.getElementsAnnotatedWith(MyAnnotation.class)) {
// Execute annotated method???
}
}
}
PS. Sorry for my english.
Diego.