Gradle 4 - replacing deprecated Test::testClassesDir

When replacing this deprecated method, which shall we prefer:

  testClassesDirs = files(sourceSets.integrationTest.output.classesDir)

or

  testClassesDirs = sourceSets.integrationTest.output

Strictly speaking, the latter will also bring the resources into the classpath. Is that a good thing?

Neither :slight_smile:

testClassesDirs = sourceSets.integrationTest.output.classesDirs

If you used multiple languages for the same source set, they could use separate output directories.

4 Likes

Would be nice going forward to have the typical replacements mentioned in the deprecated methods javadoc.

2 Likes

I had a similar problem when bumping from an old Gradle 2.10 to current 5.2.1 :

task integrationTest(type:Test) {
    testClassesDir = project.sourceSets.integrationTest.output.classesDir

Could not get unknown property ‘classesDir’ for integration test classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

And this fixed it:

testClassesDirs = project.sourceSets.integrationTest.output.classesDirs
1 Like

Thank you So Much for this post.