Conflicting test report dirs in samples/java/withIntegrationTests

I ran into an issue when trying to implement integration tests in a separate sourceSet like the sample in ‘withIntegrationTests’. I thought I’d share the fix in case it helps anyone else out. Maybe the sample should be updated, also.

Note: In the sample, there are no unit tests that execute (only integration tests). This issue does not appear until a unit test is added.

Basically, when the ‘test’ and ‘integrationTest’ tasks share the same report dir, it causes both test tasks to execute whenever ‘check’ runs. This is because each task modifies the other task’s outputs.

To workaround this, I had to specify a separate report dir for the ‘integrationTest’ task…

task integrationTest(type: Test, dependsOn: jar) {
    ...
    testReportDir = file("$buildDir/reports/integration-tests")
}

I’ve raised GRADLE-2301 to get the sample fixed. Thanks for the report and solution.