Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 969
rapoo.coder Avatar asked Nov 07 '14 09:11

rapoo.coder


1 Answers

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.

like image 146
Stephen C Avatar answered Oct 29 '22 05:10

Stephen C