Remote build with native Gradle

I’m porting a C++ makefile project in Gradle. This project must be compatible with an old compiler, that is located on a remote machine with IP 192.168.X.Y. I successfully managed this situation in Eclipse using a shared folder for the project, and customizing the build command as follows:

ssh user@192.168.X.Y "cd /opt/samba/projectFolder/ ; make"

How can I do the same in gradle?

Maybe I could install Gradle on the remote machine, and do

 ssh user@192.168.X.Y "cd /opt/samba/projectFolder/ ; ./gradlew releaseFOOSharedLibrary"