Tasks not waiting for their turn

I am moving a big Ant project to gradle.
Every folder that had a build.xml file got a build.gradle file. Each file imports the Ant file (ant.importBuild) and defines the tasks dependencies and input and outputs.

For example:

compile {
    dependsOn ":Vendor:aVeryLongTask:compile"
    inputs.dir "src"
    outputs.file "bin/myExec.exe"
}

The project builds fine in “sequential” mode, the tasks get executed in the right order.

If I run the build with --parallel, I think that the tasks get started at the right point, but the depending tasks do not wait for the longer tasks to terminate and produce their outputs. This causes build errors because of missing files.

How can I fix that?