Gradle Building Multi Projects Build Reverse order

The multi-project structure is like so:

Project A depends on A1 and A2. Building A auto build A1 and A2. However I would like to know how gradle can auto build A by building A1 or A2. The reason is that someone can change A1 which could introduce build bug to A, by auto building A whenever A1 or A2 is built will catch the bug.

I found the solution it is called buildDependents.

My new issue is that when trying to publish A only, it is trying to publish A1 even though I did not build A1 and I don’t want to publish A1. Any idea?