Code generation is compiled before generation is finished?

Hello

I am using MapStruct annotation processor in my project to generate some code. So nothing in particular is required in the build.gradle file apart from declaring the annotation processor:

implementation "org.mapstruct:mapstruct:${mapstructVersion}"
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"

I turned on the parallel build feature of Gradle and now I am getting from time to time some error like this:

C:\git_clones\project\module\build\generated\sources\annotationProcessor\java\main\package\to\file\GeneratedFile.java:49: error: not a statement
    List<SomeInterface>
        ^
C:\git_clones\project\module\build\generated\sources\annotationProcessor\java\main\package\to\file\GeneratedFile.java:49: error: reached end of file while parsing
    List<SomeInterface>
                                      ^

But if I go to the GeneratedFile the file is valid. So my assumption is that Gradle somehow starts to compile the classes before the annotation processor is fully finished.
Is there a way to force the compile task to wait for the annotation processor to complete?

Anyone facing this kind of behaviour?

Under the hood, Gradle is setting the “-processorpath” option to the “javac” command so annotation processing and compile are a single execution

The parallel build feature won’t allow two tasks in the same project to execute in parallel, so I suspect there’s a JavaCompile task in :projectA which is compiling the sources of :projectB.

Thanks @Lance for the lead.
It’s a multi project, however the generated mappers are used within the same sub project… I’ll retey again!