While using kotlin with gradle, compileKotlin
executes before compileJava
. I need to execute compileJava
before compileKotlin
. I tried compileKotlin.dependsOn(compileJava)
but it gives the Circular dependency build failure.
I also tried
compileJava.dependsOn = compileJava.taskDependencies.values - compileKotlin
But, it still executes compileKotlin
before compileJava
.
How can I execute compileJava
before compileKotlin
?
I faced the same problem in a spike test with gradle, Java, Kotlin, Scala and Groovy all together - not a real scenario, I recognize it!, but noticed that (by default, i.e. without any explicit configuration)
This limits my choices about the order which I can build my sources in: Java compilation can't happen before Kotlin compilation, as you told, and by converse Groovy and Scala compilation can't happen before Java compilation (which was my initial goal).
My idea is that the simplest wat to get the desired result is to split my source code into four different projects, setting up a multi-module project: this way I can move the problem from defining task dependencies (which as seen I can't control) to defining module dependencies (which I can control very simple through plan dependency management using something like compile project(':my-dependend-on-project')
in my dependant project's build.gradle
).
This is a very old question, so I suppose you already found a solution; anyway, I'm interested in your opinion about my conclusions about this topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With