Incremental build for java generated code

We use protobuf heavily in one of our projects. Think lot of (~200k) tightly coupled proto schemas in a single module. I say tightly coupled because if they were not, we would have simply broken our module up and gotten around this problem.

We are a gradle enterprise customer and have build caching enabled. We also have incremental builds configured properly.

One of the issues we see is that anytime any proto file is edited/added, all the java code gets regenerated. This is actually pretty fast with protoc (~20s).

But then, the java compile for all the generated code takes a long time (~8 mins), even though only a tiny bit of it has actually changed for most commits. Is there some way to configure gradle to get the previously cached classes from the build server, and do an incremental java build against them?