How to check maven artifact exists before publish?

I had the same requirement.
Checking can be achieved with REST from a gradle task.