Processing layouts needs to be a Gradle task. But i don't think any of them are public API s such that you can define inputs outputs properly. Data binding does what you want, process files and provide inputs for the processor, yet all of setup is integrated in AGP. It is very very difficult to do it outside AGP due to different compilation modes (dynamic modules, namespaced resources, build variants etc). AGP also hooks those tasks' output as input to kapt.
Don't get me wrong, what you want to do is totally reasonable but AGP just doesn't have the right public APIs to do that.
If it is for your own project, you can make it work by hacking internals but for a public library, it is a losing battleš