Brienne Tyrell
Brienne Tyrell

Reputation: 1

Force IntelliJ to rerun anntoation processors?

Is there any way to rerun annotation processors without rebuilding the entire project?

I'm developing an annotation processor which is used in project that takes ~ 10 minutes to build from scratch and it's a bit painful to wait 10 mins to test a change...

Upvotes: 0

Views: 644

Answers (2)

Andrey
Andrey

Reputation: 16381

Annotation processor can not be run without the compiler.

If you are not using Maven or Gradle to build the project but is using the IDE's build, invoke the Build | Build Project action. This way IDE will perform an incremental build that will build only changed classes.

Upvotes: 0

Peter
Peter

Reputation: 5164

General Aspect

This sounds like you don't have a proper testing approach for your annotation processor.

If you do testing always in an integrated environment, you will always have the problem of long running tests. This applys to any test environment that depens on heavy task.

So, my generall advice would be to write lightwight unit tests to check you code is working as expected. That's a general advice I can give you.

This article https://blog.jooq.org/2018/12/07/how-to-unit-test-your-annotation-processor-using-joor/ from Lukas Eder - the founder of JOOQ and that uses java annotation processors as well - is about unit testing java annotation processors.

Only Run Annotation Processors

Intellij Idea

AFAIK there is no way to do this.

Maven

If your project runs on maven, you can trigger annotation processors by just execution the generate-sources phase.

Upvotes: 1

Related Questions