I have some fairly long tests in my buildSrc build which I sometimes want to skip during development, to see the effect that template changes have. It's a report generator and sometimes I just want to tweak the templates without having to update all the tests; then later I will update them when I'm happy with the output.
I was able to implement skipping tests within the buildSrc build.gradle with the following configuration:
test {
// skip all tests if gradle run with -Pnotests
try { if (project.ext.notests != null)
println "skipping tests"
exclude '**'
} catch (MissingPropertyException e) {}
}
(and if you have a better way to detect an optional parameter I'd love to see it)
However, this doesn't work from the main gradle project. I have tried everything I can think of to try to pass the parameter through configuration, short of setting an environment variable, but I doubt that would work either.
In general I find I can't configure buildSrc whatsoever from the main project. I can't find any way to get at variables, eg project.ext.foo or ext.foo, nor a way to configure the buildSrc 'project' as there is no section in main build.gradle. It's like it exists on an island of its own. I've tried:
Is there a way around this, or do I have to refactor my whole project to move the reporting code elsewhere and maybe then I can configure it and skip tests?
Thanks in advance.
buildSrc
is a separate build (not project), and I'm not aware of a way to influence its execution when triggering the main build. (Note that building buildSrc
is a prerequisite for evaluating the main build's build scripts.) Some solutions I can think of:
buildSrc
tests for as long as required (e.g. by setting test.disabled = true
in buildSrc/build.gradle
)buildSrc
into a separate buildTest
task that's only triggered manuallyPS: The easiest way to skip a build's tests from the command line is -x test
. The existence of a project property foo
can be detected with project.hasProperty("foo")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With