Using groovy tests for kotlin class

I have an exercise that uses kotlin tests on kotlin code, built by gradle. It works.

I amended the build file by adding a the grovvy plugin, and a testCompile dependecy for spock.

Running the build file gives errors in the groovy test file where it can not find the kotlin class.

The kotlin is compiled before the test code.

buildscript {
  ext.kotlin_version = '1.3.31'
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  }
}

apply plugin: 'kotlin'
apply plugin: 'groovy'

repositories {
  mavenCentral()
}

dependencies {
  compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  testCompile "org.spockframework:spock-core:1.3-groovy-2.5"
  testCompile 'junit:junit:4.12'
  testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
}

compileTestGroovy {
    dependsOn tasks.getByPath('compileKotlin')
    classpath += files(compileKotlin.destinationDir)
}

test {
  testLogging {
    showStandardStreams = true
    exceptionFormat = 'full'
    events = ["passed", "failed", "skipped"]
  }
}