5

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?

brunobowden
  • 1,492
  • 19
  • 37
rapoo.coder
  • 133
  • 1
  • 2
  • 7
  • `apt` also always compiled the sources. The only effect of `-nocompile` was that the compiled class files were not stored on the hard drive. – Holger Nov 07 '14 at 10:27
  • ok i didnt knows that but in javac this option is not available. Is there something different with same functionality or close functionality? – rapoo.coder Nov 07 '14 at 10:39
  • Maybe `-proc:only` comes close to it but I haven’t tried. – Holger Nov 07 '14 at 10:46

1 Answers1

6

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.

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216