This is a collection of handy Gradle plugins I end up using over and over.
Adds integration testing to Gradle projects, supporting java, groovy and scala. It's completely dynamic, so it'll only add source directories for the source plugins you have (e.g. java, resources and groovy but not scala).
- It'll automatically pick directories under
src/integration-test/that matchjava,resources,groovyandscala, depending on whether you have any (or all) of those plugins enabled.
apply from: 'https://raw.github.com/brunodecarvalho/gradle-plugins/master/integration-test.gradle'To add to all subprojects of a multi-project build:
subprojects {
apply from: 'https://raw.github.com/brunodecarvalho/gradle-plugins/master/integration-test.gradle'
}If you're building projects with IntelliJ idea, you can automatically add the integration test sources by configuring the module model's test sources:
idea {
// ...
module {
testSourceDirs += file('src/integration-test/java')
}
}Or, if you're using a multi-project build:
// On the root project's build.gradle
subprojects {
// ...
idea {
module {
testSourceDirs += file('src/integration-test/java')
testSourceDirs += file('src/integration-test/groovy')
}
}
}A picture worth a thousand words:
apply from: 'https://raw.github.com/brunodecarvalho/gradle-plugins/master/colored-test-output.gradle'Adds coverage reports for multi-project Gradle projects.
- Root project has no code;
- Coverage tracking is only done for submodules;
- A single coverage report is generated which aggregates all coverage data from subprojects.
Apply on the root build.gradle project:
allprojects {
apply from: 'https://raw.github.com/brunodecarvalho/gradle-plugins/master/jacoco-multiproject-aggregator.gradle'
}The plugin must be applied to all subprojects. Here's what happens:
- If the project is a subproject, it introduces a pre-
testhook to run JaCoCo agent and track coverage; - If the project is the root project, a new task,
coverageReport, is created.
The coverageReport task depends on test task so from a clean project, running gradle coverageReport will test the code and generate a coverage report.
MIT.
