Removing/reordering task dependencies

Hello,

I have a project that unfortunately uses both Scala and Kotlin in tests. The problem is, that the plugins order the dependencies in such way, that compileTestScala runs after compileTestKotlin. However my code is actually exactly the other way, that is scala classes are used from kotlin (and never the opposite way).

I tried to fix this by using mustRunAfter and setDependsOn, but I always ended in circular dependencies. After some experimenting, I found out, that the problem is that setDependsOn works for some tasks, but has no effect for others.

For example this works:

tasks.testClasses {
    setDependsOn(listOf(tasks.classes, tasks.compileTestScala))
}

while this doesn’t (compileTestScala still depends on compileTestJava):

tasks.compileTestScala {
    setDependsOn(listOf(tasks.classes))
}

So my question is: Is this actually the correct way to remove dependencies? Or am I missing some better way to handle this?

1 Like