Android multi modules annotation processing

In a multi modules Android project annotation processing is still executed as a first task before any compilation is done and then a complete compilation is triggered. Of course this is done per module before getting into the app module.

Imagine a case where some child modules depend on others, the compilation will fail as the dependant cannot yet find definition for generated classes in the module that it depends on simply because they were not generated yet.

I am wondering if there’s a way either using gradle or anything else to force execute all child modules annotation processing first and then compile the whole project in an automatic fashion. This means if I have 3 modules let’s name them app, services and executors where services depends on executors.

What I am seeking is that the build tree would go in this order:

  1. annotation processing is executed for all modules without compilation
  2. a full project compilation is then invoked

I found so far some promising lead using the java compiler's option -proc:{none;only} where the value only should invoke the annotation processing without any further compilation. I have tried passing this option to my compiler but still the compilation goes sequentially child module per child module.

Any ideas?