如何在不使用 javac 编译源代码的情况下运行 Annotation Processor(Java 8 不能使用 Apt) [英] How to Run Annotation Processor without compiling sources using javac (Java 8 can't use Apt)
问题描述
如何在不使用 javac 编译源代码的情况下运行 Annotation Processor(Java 8 不能使用 Apt)?
How can i Run Annotation Processor without compiling sources using javac (Java 8 can't use Apt)?
javac 有没有参数可以只运行注解处理而不编译所有文件?
Is there any parameter for javac that could run only annotation processing without compiling all files?
我想用 javac 做什么:
What i want to do by javac:
只需找到带注释的元素并使用定义的注释处理器使用
-processor
标志来处理它们
不要编译任何没有任何注释的源
do not compile any source that doesn't have any annotation
因为我想在 Java 8 上执行此操作,所以不可能将 Apt 用于此任务?或者也许是?
Because i want do this on Java 8 it's impossible to use Apt for this task? Or maybe it is?
推荐答案
apt
工具在 Java 8 中不可用.基于 此处,将 apt
移植到 Java 8 并非易事.
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.
根据javac
手动输入:
-proc: [无,只有]
-proc: [none, only]
控制注解处理和编译是否完成.-proc:none
表示编译在没有注释处理的情况下进行.-proc: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.
听起来像 -proc:only
会做你想做的事.如果没有,那么您需要寻找第三方工具,或者自己开发工具.
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.
这篇关于如何在不使用 javac 编译源代码的情况下运行 Annotation Processor(Java 8 不能使用 Apt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!