Java multi project incremental build

I have a multi project build that applies the Java plugin.
I have a default task that depends on classes that produces some files. It does more than this so it can’t be of type Java.

I have problem setting the correct inputs to this task in order to get incremental build to work.
if i set “inputs.files classes.outputs.files” then the task is correctly out-of-date if i modify java file in the master project. But the task is wrongly up-to-date if I modify a java file in a sub-project.

I need a way to set all class files and resources for all projects in this build as input to this task.