Implicit task dependency with single output


due to problems with WELD on the module path(java - Bean discovery problems when using weld-se with Gradle application plugin - Stack Overflow), I am setting the output path for resources to the classes output path like this:

sourceSets {
        main {
            output.resourcesDir = 'build/classes/main'
        test {
            output.resourcesDir = 'build/classes/test'

This all works fine but now I receive a lot of warnings by Gradle like this:

Execution optimizations have been disabled for task ':project-b:compileTestJava' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/workspace/project-a/build/classes/main'. Reason: Task ':project-b:compileTestJava' uses this output of task ':project-a:processResources' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to for more details about this problem.

I understand that this is because processResources writes to build/classes/main just like I configured and project-b has a api dependency on project-a.

The question is, how to get rid of this warning?

I tried the following without success:

    compileJava {
        finalizedBy processResources
    compileTestJava {
        finalizedBy processTestResources

Any ideas?