Running integrationTest task with subprojects result in build errors


(Jason Harrison) #1

I have a project with two subprojects. Project subA has unit and integration tests.

I’ve added an integrationTest task to my top level project:

// add the integration tests
task integrationTest(dependsOn: ":subA:integrationTest") {
    group = LifecycleBasePlugin.VERIFICATION_GROUP
    description = 'Runs the integration tests.'
    mustRunAfter tasks.test
}

When I execute the command gradle clean build I get the expected tasks done by gradle:

:subA:clean
:subB:clean
:clean
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar
:subB:processResources
:subB:processTestResources UP-TO-DATE
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
:subA:compileJava
:subA:processResources
:subA:classes
:subA:jar
:subA:assemble
:subB:compileJava
:subA:processTestResources
:subA:copyTestResources
:subA:copyTestResources
:subA:compileTestJava
:subB:classes
:subB:war
:subA:testClasses
:subA:test
:subB:assemble
:subB:compileTestJava UP-TO-DATE
:subB:testClasses UP-TO-DATE
:subB:test UP-TO-DATE
:subB:check UP-TO-DATE
:subB:build
:subA:copyIntegrationTestResources
:subA:copyTestResources
:subA:compileIntegrationTestJava
:subA:processIntegrationTestResources UP-TO-DATE
:subA:integrationTestClasses
:subA:integrationTest
:subA:check
:subA:build

But when I immediately afterwards execute the command gradle integrationTest I get an unexpected build of subproject subB with build errors because it doesn’t seem to process any of the subproject dependencies:

:subA:compileJava UP-TO-DATE
:subB:compileJava
:subA:processResources UP-TO-DATE
:subA:classes UP-TO-DATE
:subA:processTestResources UP-TO-DATE
:subA:copyTestResources
:subB:compileJava FAILED
:subB:processResources UP-TO-DATE
:subB:processTestResources UP-TO-DATE
:subA:compileTestJava UP-TO-DATE
:subA:testClasses UP-TO-DATE
:subA:test UP-TO-DATE
:subA:copyIntegrationTestResources
:subA:copyTestResources
:subA:compileIntegrationTestJava UP-TO-DATE
:subA:processIntegrationTestResources UP-TO-DATE
:subA:integrationTestClasses UP-TO-DATE
:subA:integrationTest
:subA:jar UP-TO-DATE
:subA:assemble UP-TO-DATE
:subA:check
:subA:build

After the build errors, the integration tests of subA are run correctly, but the overall result is BUILD FAILED.

Why is sub:compileJava being called for task integrationTest? This occurs if I execute either gradle :subA:integrationTest or cd subA; gradle :integrationTest

-Jason