On mac based on this gist and this answer to find the folder do:
Create file speak.gradle with below content inside ~/.gradle/init.d folder (if you can't find init.d folder, you can create it)
speak.gradle
// When runnning a Gradle build in the background, it is convenient to be notified immediately // via voice once the build has finished - without having to actively switch windows to find out - // and being told the actual exception in case of a build failure. // Put this file into the folder ~/.gradle/init.d to enable the acoustic notifications for all builds gradle.addBuildListener(new BuildAdapter() { @Override void buildFinished(BuildResult result) { def projectName = gradle.rootProject.name if (result.failure) { playSound('Submarine.aiff') def e = getExceptionParts(result) "say '$projectName build failed: ${e.first} ${e.second}.'".execute() } else { if (projectName != "buildSrc") { playSound('Glass.aiff') "say '$projectName build successful.'".execute() } } } private Tuple2<String, String> getExceptionParts(BuildResult result) { def exception = result.failure if (exception.cause != null) { exception = exception.cause } def className = exception.class.simpleName def of = className.indexOf('Exception') new Tuple2<String, String>(className.substring(0, of), className.substring(of)) } private void playSound(def sound) { "afplay /System/Library/Sounds/$sound".execute() sleep(100) } })
you can simplify more the sound to done and fail