如何配置不使用Maven外部JAR注释处理API? [英] How to configure the Annotation Processing API without external Jar using Maven?
本文介绍了如何配置不使用Maven外部JAR注释处理API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的项目中使用自定义的注释。
I would like to use a custom annotation in my project.
如何配置的行家3 处理我的注释。注释和AbstractProcessor类的实现嵌入在我的申请。
How can I configure maven 3 to process my annotation. The annotation and the implementation of the AbstractProcessor class are embedded in my application.
我的注释仅用于测试中(src / test / java下)。
My annotation is available only for testing (src/test/java).
国家注释:
@Target(ElementType.METHOD)
public @interface State {
boolean success() default true;
}
TestAnnotationsProcessor:
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;
}
}
我不想把我的注释在外部项目......这将是愚蠢的,因为它确实dependend我的项目。
我怎样才能做到这一点?谢谢你。
How can I do that ? Thanks.
推荐答案
您可以做类似(原谅我,如果语法是有点过,我没有我的IDE方便):
Could you do something like (forgive me if the syntax is a little off, I don't have my IDE handy):
<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>
这篇关于如何配置不使用Maven外部JAR注释处理API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文