Created
April 21, 2010 16:09
-
-
Save virasak/374023 to your computer and use it in GitHub Desktop.
error message filter for sbt and redirect to 'error' file. In vim call ':cf target/error' or 'set errorfile=target/error' and then call ':cf'.
This file contains hidden or 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
#!/bin/bash | |
sbt "$@" | tee >( awk ' | |
BEGIN { | |
error_file = "target/error"; | |
} | |
END { | |
system("rm " error_file); | |
} | |
{ | |
gsub(/\033\[[0-9]*m/, ""); | |
} | |
/^\[info\] Building project/ { | |
project_name = $4 "-" $5; | |
scala_version = $NF; | |
} | |
/^\[info\] Total time/ { | |
close(error_file); | |
system("sed -i \"/\\[info\\]/d\" " error_file); | |
# comment this block if notify-send is unavailable | |
error_msg = "\"" project_name " compile fail for " scala_version "\""; | |
success_msg = "\"" project_name " compile success for " scala_version "\""; | |
system("if [ -s " error_file " ]; then notify-send -i error " error_msg "; else notify-send -i info " success_msg "; fi;"); | |
} | |
/^\[info\] == compile ==/ { | |
inner = !inner; | |
} | |
/^\[info\] == test-compile ==/ { | |
inner = !inner; | |
} | |
inner { | |
print > error_file; | |
} | |
') | |
This file contains hidden or 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
java -Xmx1024M -Dsbt.log.noformat=true -jar `dirname $0`/sbt-launch.jar "$@" |
This file contains hidden or 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
" Vim Compiler File sbt.vim | |
" Compiler: sbt | |
if exists("current_compiler") | |
finish | |
endif | |
let current_compiler = "sbt" | |
set makeprg=sbt-without-color\ test-compile | |
set errorformat=%E[error]\ %f:%l:\ %m,%C[error]\ %p^,%-C%.%#,%Z, | |
\%W[warn]\ %f:%l:\ %m,%C[warn]\ %p^,%-C%.%#,%Z, | |
\%-G%.%# | |
set errorfile=target/error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment