java - Gradle: how can I use dynamic properties on multiple tasks to fail a build? -
one of build tasks pulls information on current svn branch. on builds tag want more strict , fail build when e.g., link checker finds dead links online files. on regular builds branches or trunk should not break build.
i have following code, mentioned perl script creates properties file:
task generatesvninfo(type: exec) { outputs.files "generated/svninfo" executable "perl" args "..." } properties buildprops = new properties() task svninfo() { inputs.files generatesvninfo.outputs.files outputs.uptodatewhen { false } buildprops.load(new fileinputstream(inputs.files.getsinglefile())) }
now other targets depend on svninfo
(and fact populates buildprops
).
task checkhelplinks(type: exec) { dependson "svninfo" executable "perl" args "..." }
this fail if finds dead links. far understand it, ignoreexitvalue
false
default. set true
on non-tag builds, can add checkhelplinks
task:
ignoreexitvalue = true dolast { ignoreexitvalue = buildprops.from_tag == "false" }
this works, have 4 or 5 of these check tasks , not duplicate code around. tried
tasks.grep(~ /^check.+/).each { task -> task.ignoreexitvalue = true task.dolast { task.ignoreexitvalue = buildprops.from_tag == "false" } }
this code not seem executed. thought may because compare task object string in grep
, using
tasks.grep(it.name =~ /^check.+/).each { task ->
gets me build script error ("could not find property 'it' on root project 'foo'.)
how can add tag check check tasks?
is there better way load properties file created part of build process?
is there svn plugin work me?
Comments
Post a Comment