how do i express this in gradle script kotlin ```...
# gradle
b
how do i express this in gradle script kotlin
Copy code
compileTestGroovy.dependsOn compileTestKotlin
compileTestGroovy.classpath += files(compileTestKotlin.destinationDir)
testClasses.dependsOn compileTestGroovy
g
compileTestGroovy
and testClasses are tasks, so you should use corresponding kotlin dsl api for that
e
The task might have an accessor already generated or not depending on how the plugin is applied and it will be generated as an extension of type
TaskProvider<T>
on
TaskContainer
so in your
build.gradle.kts
Copy code
tasks {

  val compileTestKotlin by existing(KotlinCompile::class)

  compileTestGroovy.get().dependsOn(compileTestKotlin)
  compileTestGroovy.get().classpath += files(compileTestKotlin.get().destinationDir)
testClasses.get().dependsOn(compileTestGroovy)
}
Unfortunately the generated accessor for
compileTestKotlin
is generated with a wrong task type of `Any`and this will not work without you adding the first line and explicitly supplying the
KotlinCompile
type. If you want to do this the recommended Gradle way (ie with lazy configuration) use configuration blocks on the task providers
Copy code
tasks {
  val compileTestKotlin by existing(KotlinCompile::class)

  compileTestGroovy {
    dependsOn(compileTestKotlin)
    classpath += files(compileTestKotlin.get().destinationDir)
  }

  testClasses {
    dependsOn(compileTestGroovy)
  }
}
b
Thanks, let me try that
g
The task might have an accessor already generated or not depending on how the plugin is applied
Correct. And official docs (which I sent above) are really good and explain this thing
1
b
I got it to work, but it was not related to this, the groovy plugin was not applied because of an error in out gradle plugin.