Atomic publish in multi-project

I have a multi-project. Currently, if I do “gradle publish”, Gradle will build the first sub-project, publish it, then start building the second project. If there is an error building the second project, I end up with an inconsistent set of published artifacts.

With the old way of publishing I could do something like this:

allprojects { parent ->

parent.tasks.withType(Upload) { task ->

allprojects { child ->

task.dependsOn child.tasks.check



} }

How can I do this with the new ivy-publish approach?