Command whenchange monitors for changes on files, directories, and optionally watching sub-directories, and when a change happens, executes a command.
go get ronoaldo.gopkg.net/whenchange
whenchange -p source.go go build
The above command will monitor all go files in the current directory for changes, and trigger go build.
whenchange -p ./src/ mvn test-compile
The above command will monitor recursivelly the src folder, and execute the maven test compile target.