Test task scan directory

(Nikita Skvortsov) #1

My plugin creates additional classes dir (kotlin-classes/[sourceSetName]) to a SourceSet output. It is needed to do correct cross compilation with java Jar task successfully handles this (adds compiled classes to jar archives).

But Test task seems to ignore this directory when scanning for test classes. Is there any way for single Test task to scan several classes directories? (e.g., java and kotlin)

(Luke Daley) #2

The ‘Test’ task type currently only handles scanning one directory. You’ll have to aggregate the classes yourself…

task aggregateTestClasses(type: Copy) {
  from compileTestJava
  from compileTestKotlin
  into "$buildDir/classes/test-java-and-kotlin"
  test {
  dependsOn aggregateTestClasses
  testClassesDir aggregateTestClasses.destinationDir

(Nikita Skvortsov) #3

I see. Thank you.

(Peter Niederwieser) #4

The ‘Test’ task type assumes a single test classes directory (‘testClassesDir’). By default, Gradle’s Java, Groovy, and Scala plugins all compile into the same output directory (also when joint-compiling). The separation is per source set, not per language.