bjartek
03/14/2019, 7:27 AMcompileTestGroovy.dependsOn compileTestKotlin
compileTestGroovy.classpath += files(compileTestKotlin.destinationDir)
testClasses.dependsOn compileTestGroovy
gildor
03/14/2019, 7:45 AMcompileTestGroovy
and testClasses are tasks, so you should use corresponding kotlin dsl api for thatefemoney
03/14/2019, 7:50 AMTaskProvider<T>
on TaskContainer
so in your build.gradle.kts
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
tasks {
val compileTestKotlin by existing(KotlinCompile::class)
compileTestGroovy {
dependsOn(compileTestKotlin)
classpath += files(compileTestKotlin.get().destinationDir)
}
testClasses {
dependsOn(compileTestGroovy)
}
}
bjartek
03/14/2019, 8:15 AMgildor
03/14/2019, 8:31 AMThe task might have an accessor already generated or not depending on how the plugin is appliedCorrect. And official docs (which I sent above) are really good and explain this thing
bjartek
03/14/2019, 9:38 AM