如何将 Cobertura 插件应用于所有项目或所有子项目
How to apply Cobertura plugin to all projects or all subprojects
我正在尝试将 Cobertura 插件应用于我的 Gradle 构建脚本中的所有项目和子项目。但是,脚本无法在应用于所有插件时找到插件。这是我得到的:
buildscript {
repositories {
jcenter()
}
}
allprojects {
beforeEvaluate {
project.buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.2.7'
}
}
}
}
subprojects {
apply plugin: 'net.saliman.cobertura'
}
build.gradle
应该是这样的:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.2.7'
}
}
allprojects {
apply plugin: 'net.saliman.cobertura'
}
您可能还会发现您想要将所有子项目的 cobertura 报告合并到一个漂亮的整个项目的顶级报告中。
要做到这一点,你需要 cobertura gradle 插件 2.2+ 我相信它的配置是这样的:
// note - all non-cobertura config is stripped out of this example
allprojects {
apply plugin: 'cobertura'
}
subprojects {
cobertura {
coverageIgnoreTrivial = true
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.2.2"
}
}
def files = subprojects.collect { new File(it.projectDir, '/build/cobertura/cobertura.ser') }
cobertura {
coverageFormats = [ 'xml', 'html' ]
coverageSourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
coverageMergeDatafiles = files
}
test.dependsOn(subprojects.test)
这是来自 syncsynchalt 对这里问题的精彩评论:
https://github.com/stevesaliman/gradle-cobertura-plugin/issues/10
我正在尝试将 Cobertura 插件应用于我的 Gradle 构建脚本中的所有项目和子项目。但是,脚本无法在应用于所有插件时找到插件。这是我得到的:
buildscript {
repositories {
jcenter()
}
}
allprojects {
beforeEvaluate {
project.buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.2.7'
}
}
}
}
subprojects {
apply plugin: 'net.saliman.cobertura'
}
build.gradle
应该是这样的:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.2.7'
}
}
allprojects {
apply plugin: 'net.saliman.cobertura'
}
您可能还会发现您想要将所有子项目的 cobertura 报告合并到一个漂亮的整个项目的顶级报告中。
要做到这一点,你需要 cobertura gradle 插件 2.2+ 我相信它的配置是这样的:
// note - all non-cobertura config is stripped out of this example
allprojects {
apply plugin: 'cobertura'
}
subprojects {
cobertura {
coverageIgnoreTrivial = true
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "net.saliman:gradle-cobertura-plugin:2.2.2"
}
}
def files = subprojects.collect { new File(it.projectDir, '/build/cobertura/cobertura.ser') }
cobertura {
coverageFormats = [ 'xml', 'html' ]
coverageSourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
coverageMergeDatafiles = files
}
test.dependsOn(subprojects.test)
这是来自 syncsynchalt 对这里问题的精彩评论: https://github.com/stevesaliman/gradle-cobertura-plugin/issues/10