Running Tasks on Subprojects

I’d like to create a task that is capable of running tasks on subprojects.

For example, I’d like to publish a subset of my subprojects using a task in my root build.gradle called publishApi

The publishApi task would in turn invoke :storage:api:publish and rest:api:publish.

Is there a way to acheive this?

Maybe these links can help you: