We have some existing configuration to build a testJar artifact which looks something like this:
configurations {
tests {
extendsFrom testRuntime
}
}
artifacts {
tests testJar
}
task testJar(type: Jar, dependsOn: [testClasses, forbiddenApisTest]) {
classifier = 'tests'
destinationDir = file("${projectDir}/build")
from sourceSets.test.output
}
Because class loading is much faster from a jar than from files on the filesystem, I would like to now run the test
task from this jar in order to speed up the tests. This is something we had working in the Ant build, but lost as part of the Gradle migration.
What’s the proper way to customise the Test
task so that this works and properly sets up the dependencies?