We have a multi-project build, and I am trying to apply a third-party plugin to all of the individual projects (in particular, the gradle-cobertura-plugin to provide code coverage metrics).
I currently have a solution that works, but it requires the following code to be inserted into every individual project’s build script (‘maven-main-cache’ is defined in another script):
buildscript {
repositories {
add project.repositories.'maven-main-cache'
}
dependencies {
classpath group: 'net.saliman', name: 'gradle-cobertura-plugin', version: '1.1.2'
}
}
apply plugin: 'cobertura'
cobertura {
coverageFormats = [ 'xml' ]
}
This code has to be manually added to any new projects, and pretty much doubles the length of all our build scripts. Ideally I want to factor this code out into a separate file that can be included in each build script using the “apply from” syntax.
The solution from here looks like it should work, but the buildscript.gradle file doesn’t seem to have access to properties defined in gradle.properties, so cannot find basic things we define there, such as repository location or user credentials, even if I try to refer to the repository directly rather than through the project.repositories object.
Is my approach to this just all wrong?