although question involves c language, gradle c plugin, , oldschool c static analyzer called splint, believe question can answered gradle guru understands how wire gradle build executable process.
it's simple: have configured splint locally analyze simple c project's source code following command line:
splint +never-include -retvalint src/derpus/c/*.c
i managing project's build via gradle (the c plugin), , invoke static analysis (splint) @ appropriate point in build sequence (whatever may be).
splint outputs console, , unfortunately no else. , see if can "hook" console output, check keywords ("error", "warning", etc.) , fail/halt build if splint complained anything.
and i'm trying tackle several problems here:
- how invoke splint gradle, , @ appropriate stage? instance, whenever codenarc executes (after compile? after running tests?) when splint should invoked.
- how pass correct command-line args splint invocation?
- how hook splint's console output?
- how fail build when console output contains keywords?
my best attempt far is:
task check(type:exec) { commandline 'cmd', '/c', 'c:/splint-3.1.1/bin/splint.exe', '+never-include', '-retvalint', 'src/derpus/c/*.c' standardoutput = new bytearrayoutputstream() dolast { string output = standardoutput.tostring() if(output.contains("error") || output.contains("")) { println "chuggington!" } else { println "meeska! mooseka! mickey mouse! output is: ${output}" } } }
this produces:
defining custom ▒check▒ task deprecated when using standard lifecycle plugin has been deprecated , scheduled removed in gradle 3.0 :checksplint 3.1.1 --- 12 april 2003 finished checking --- no warnings chuggington! build successful total time: 3.327 secs
however i'm 100% confident workingdir
, commandline
args incorrect, i'm not sure how can fail/halt build inside if
-statement, , i'm not sure how "position" check
task occur before compilation , testing.
any ideas, gradle gurus?
workingdir
directory tool should run not it's located. typically it's project directory. when comes commandline try:
commandline 'cmd', '/c', 'splint.exe', '+never-include', '-retvalint', 'src/derpus/c/*.c'
in command above arguments should separated comma: ,
.
you can omit assignment operator =
.
when comes parsing output - doesn't work because in closure it's not generated yet. try:
standardoutput = new bytearrayoutputstream() dolast { string output = standardoutput.tostring() if(output.contains("error") || output.contains("")) { println "chuggington!" } else { println "meeska! mooseka! mickey mouse!" } }
Comments
Post a Comment