开发者

How to define myAnnotationProcessor programmatically in source code?

开发者 https://www.devze.com 2023-03-20 13:49 出处:网络
I\'m just new to annotations. I\'ve created开发者_高级运维 a sample annotationProcessor to handle my annotations and currently using command line script \"-processor defaultproject.annotations.Default

I'm just new to annotations. I've created开发者_高级运维 a sample annotationProcessor to handle my annotations and currently using command line script "-processor defaultproject.annotations.DefaultProcessor " to use it.

is there any way to set this processor from inside the code?

thanks a lot Moein


The Processor interface says this about the discovery process:

The tool uses a discovery process to find annotation processors and decide whether or not they should be run. By configuring the tool, the set of potential processors can be controlled. For example, for a JavaCompiler the list of candidate processors to run can be set directly or controlled by a search path used for a service-style lookup. Other tool implementations may have different configuration mechanisms, such as command line options; for details, refer to the particular tool's documentation.

Your best bet for defining the processor in your classpath is to provide a META-INF/services/javax.annotation.processing.Processor file containing the text defaultproject.annotations.DefaultProcessor.

(Assuming your tool chain supports this mechanism. This is ultimately compiler/tool/IDE dependent.)

0

精彩评论

暂无评论...
验证码 换一张
取 消