Gradle mixed source language set compilation order

Viewed 525

I'm using gradle, and I've inherited a project with all of Java, Groovy, and Kotlin. I'm trying to convert the project down to just one language, but in the interim I need to get a specific compilation order working: Java first, then Kotlin, then Groovy.

I thought I could just do this in the build.gradle:

 compileJava.dependsOn = compileJava.taskDependencies.values - 'compileKotlin'
 compileKotlin.dependsOn compileJava
 compileGroovy.dependsOn compileKotlin
 classes.dependsOn compileGroovy
 compileGroovy.classpath += files(compileKotlin.destinationDir)

Based on some stuff I read here: https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/8

But I end up with a circular dependency that looks like this:

* What went wrong:
Circular dependency between the following tasks:
:demo:compileJava
     \--- :demo:compileKotlin
         \--- :demo:compileJava (*)

If I read that correctly, it looks like it's telling me that compileJava depends on compileKotlin, but I've explicitly removed that dependency, so I'm not sure what's going on.

0 Answers
Related