As described in Gradle Test Dependency and Multi-project test dependencies with gradle, the solution for cross-project test dependencies is to define something like
task testJar(type: Jar, dependsOn: testClasses) {
from sourceSets.test.java
classifier "tests"
}
configurations {
tests
}
artifacts {
tests testJar
}
in the depended-upon project and
dependencies {
testCompile project(path: ':aProject', configuration: 'tests')
}
in the dependent project.
But the answers there mention Gradle 1.x, a few 2.x. In Gradle 3.5 this gives me
Error:(22, 0) Could not get unknown property 'testClasses' for project ':communicator-api' of type org.gradle.api.Project.
and removing the dependsOn: testClasses
gives
Error:(23, 0) Could not get unknown property 'sourceSets' for task ':communicator-api:testsJar' of type org.gradle.api.tasks.bundling.Jar.
How to define testJar
in Gradle 3.x or 4.x? Or is there a more standard solution now?