Remove task dependency assemble <- jar

By default, “assemble” depends on “jar”. Is there a way to remove this dependency?

I have a Java project where I am not using the “jar” task (my project produces other artifacts).
I would like to attach the “dist” task in my project to the assemble task, but don’t want the “jar” task to run.

I have tried:


but this fails as follows:

Removing a task dependency from a task instance is not supported

(this is Gradle 6.7.1).

Is there any way to achieve this?

What’s your true requirement here? It’s far more typical to just set jar.enabled = false if you don’t need to generate a JAR in this project and therefore never want it to run. It’s technically still a dependency of assemble, but the task will always be SKIPPED. Is that good enough?

Setting jar.enabled = false is what I am doing now, but I was hoping for a way to entirely remove the jar task, which I don’t have any use for.