How to Run Annotation Processor without compiling sources using javac (Java 8 can't use Apt)

拟墨画扇 提交于 2019-12-23 11:52:35

问题


How can i Run Annotation Processor without compiling sources using javac (Java 8 can't use Apt)?

Is there any parameter for javac that could run only annotation processing without compiling all files?

What i want to do by javac:

  • Just find annotated elements and process them using defined annotation processor using -processor flag

  • do not compile any source that doesn't have any annotation

Because i want do this on Java 8 it's impossible to use Apt for this task? Or maybe it is?


回答1:


The apt tool is not available in Java 8. Based on what is said here, porting apt to Java 8 would not be straight-forward.

According to the javac manual entry:

-proc: [none, only]

Controls whether annotation processing and compilation are done. -proc:none means that compilation takes place without annotation processing. -proc:only means that only annotation processing is done, without any subsequent compilation.

It sounds like -proc:only would do what you want to do. If not, then you would need to look for a 3rd-party tool, or develop a tool yourself.



来源:https://stackoverflow.com/questions/26798154/how-to-run-annotation-processor-without-compiling-sources-using-javac-java-8-ca

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!