Maven builds often take some time. This often causes me to start doing something else (read mail, browse web), which makes me unaware of when the build completes and I can continue working.
There should be a way to fix this. On Ubuntu, you get notifications when mail arrives, when network is up/down etc. Why not use this same system to get notifications when the maven build completes.
You can do this by adding the following in your ~/.bash_aliases file:
alias maven="command mvn" notified_maven() { maven $* ; notify-send --icon=message-im "mvn" "build finished" } alias mvn=notified_maven |
Update
Thanks to Adrien, you can also use a more advanced version, showing the build result and maven parameters.
alias maven="command mvn" notified_maven() { maven $* | \ perl -pe'$m|=/BUILD .*SUCCESS/; END {exit!$m}' && \ notify-send --icon=face-cool "`basename $(pwd)`: mvn $*" "Build SUCCESS" || \ notify-send --icon=face-crying "`basename $(pwd)`: mvn $*" "Build FAILED" } alias mvn=notified_maven |
Nice idea, here is an updated version :
alias maven=”command mvn”
notified_maven() {
maven $* &&
notify-send –icon=/home/user/success.png “`basename $(pwd)` : mvn $*” “Build SUCCESS” || notify-send –icon=/home/user/error.png “`basename $(pwd)`: mvn $*” “Build FAILED”
}
alias mvn=notified_maven
Thanks for the input Adrien. Added your suggestion in the text. I did need an additional step as maven did not give correct exit codes on my system (using maven 3.0.4).
[…] Disponible avec le paquet libnotify-bin sous ubuntu : Intégration de notify-send avec Maven. […]