问题
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
flagdo 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