How to automate build in gradle?

Whenever I edit something in the build.gradle file I need to sync it, but this is available only in the ide s to sync but I don’t want to install android studio or anything in Linux (cause : GUI is not installed in it)
How can I sync Gradle in the terminal
gradlew sync does not work it shows errors but if the same project is synced on my windows machines the gradle commands starts working.

Longstory short I want a way to sync gradle in terminal itself.

I’m not sure what you are trying to synchronize? What errors are shown by the sync task?

I’m not an Android developer, so unfortunately I’m not familiar with its Gradle plugins.

Actually, I managed to solve the problem by upgrading the Gradle version to 7.6 and there is no error.
Alternatively installing a local copy of Gradle and trying to build from it would also work.