Last active
June 26, 2024 14:01
-
-
Save fayaz07/3d60f00b84c0ed9173cf289fb5c35909 to your computer and use it in GitHub Desktop.
🚧 voice out android project's build status(Global configuration)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Place the file at $HOME/.gradle/init.d/speak.gradle | |
**/ | |
gradle.ext.projectName = "" | |
gradle.ext.taskMapping = [ | |
'assembleDevDebug': 'Running debug build', | |
'connectedCheck': 'Running UI Tests', | |
'connectedDevDebugAndroidTest': 'Running UI Tests - with dev flavour and debug mode', | |
'connectedProdDebugAndroidTest': 'Running UI Tests - with prod flavour and debug mode', | |
'ktlint': 'Running lint checks', | |
'testDevDebugUnitTest': 'Running unit tests - with dev flavour debug mode' | |
] | |
def speak(text) { | |
def process = "say -v Karen \"${text}\"".execute() | |
process.waitFor() | |
} | |
gradle.buildFinished { buildResult -> | |
def tasks = gradle.gradle.taskGraph | |
if (buildResult.failure) { | |
speak("Build failed. Cause for failure: ${buildResult.failure.message}") | |
} else { | |
speak("Build success.") | |
} | |
} | |
gradle.beforeProject { project -> | |
if (project.name != "app") { | |
gradle.projectName = project.name | |
} | |
} | |
gradle.taskGraph.whenReady { graph -> | |
def taskName = graph.getAllTasks().last().name | |
def runCommand = gradle.taskMapping[taskName] | |
if(runCommand == null){ | |
runCommand = "Running ${taskName}" | |
} | |
speak("${runCommand} in project ${gradle.projectName}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment