Hi All,
I really like the “gradle build -t” option to immediately see if unit-tests are failing.
Is there are way to tell gradle to clear the screen when it detects a change an runs the build? This would make it much easier for the eye to see what is going on as it would always be on the top of the terminal window instead of adding content at the end.
I hope it is understandable what i want: I don’t want to see the output of the previous runs in the terminal window; only always the latest run.
the solution works great. as i wont to get familiar with gradle plugins, i would like to put this into my own plugin. How is the best way from within a plugin to find out if the build is running in contoinous mode; i.e. i only want to run the clear-screen in case we are running with -t parameter. in normal mode, i dont wan the clearing of the screen.
You can determine if Gradle was started in continuous mode using gradle.startParameter.continuous. When you wrap this in a plugin, you will just need to add project in front of a few lines that were implicitly delegating to project.
class ContinuousClearPlugin implements Plugin<Project> {
void apply(Project project) {
if (project.gradle.startParameter.continuous) {
project.gradle.addListener new BuildAdapter() {
void projectsEvaluated(Gradle gradle) {
project.exec { commandLine 'clear' }
}
}
}
}
}