How to configure annotation API without external Jar using Maven?

I would like to use custom annotation in my project.

How to configure maven 3 to handle my annotation. Abstract and implementation of the AbstractProcessor class are built into my application.

My annotation is only available for testing (src / test / java).

Status Annotations:

@Target(ElementType.METHOD) public @interface State { boolean success() default true; } 

TestAnnotationsProcessor:

 @SupportedAnnotationTypes("com.*****.client.State") public class TestAnnotationsProcessor extends AbstractProcessor { @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { System.out.print("TESSST ANNOTATION"); return true; } } 

I do not want to put my annotation in an external project ... it will be stupid, because it really depends on my project.

How can i do this? Thanks.

+4
source share
1 answer

Could you do something like (forgive me if the syntax is a bit off, I don't have my IDE):

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin<artifactId> <version>2.3.2</version> <executions> <execution> <goals> <goal>testCompile</goal> </goals> <phase>test-compile</phase> <configuration> <annotationProcessors>com.******.TestAnnotationsProcessor</annotationProcessors> <proc>only</proc> </configuration> </execution> </executions> </plugin> 
+2
source

Source: https://habr.com/ru/post/1394605/


All Articles