gradle - 使用 gradle 6.7 我无法汇总子项目的测试报告
问题描述
我正在尝试应用 gradle 文档的“示例 4。为子项目创建单元测试报告”,请参见此处
Root project name: root
group name: root.group.name
version: 1.0.0
我的项目具有以下结构:
/A/build.gradle
/B/build.gradle
/buildSrc/src/main/groovy/root.java-conventions.gradle
/build.gradle
root.java-conventions.gradle:
plugins {
id 'java'
}
// Disable the test report for the individual test task
test {
reports.html.enabled = false
}
// Share the test report data to be aggregated for the whole project
configurations {
binaryTestResultsElements {
canBeResolved = false
canBeConsumed = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
}
outgoing.artifact(test.binaryResultsDirectory)
}
}
在根项目的 build.gradle 中:
plugins {
// Apply the groovy Plugin to add support for Groovy.
id 'groovy'
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
}
configurations {
testReportData {
canBeResolved = true
canBeConsumed = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
}
}
}
dependencies {
testReportData project(":A")
testReportData project(":B")
}
tasks.register('testReport', TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Use test results from testReportData configuration
testResultDirs.from(configurations.testReportData)
}
我想我正确地应用了这个例子。
但是,gradle 输出以下错误:
Could not determine the dependencies of task ':testReport'.
> Could not resolve all task dependencies for configuration ':testReportData'.
> Could not resolve project :A.
Required by:
project :
> No matching variant of project :A was found. The consumer was configured to find documentation of type 'test-report-data' but:
- Variant 'apiElements' capability root.group.name:A:1.0.0:
- Incompatible because this component declares a library and the consumer needed documentation
- Other compatible attribute:
- Doesn't say anything about the documentation type (required documentation of type 'test-report-data')
- Variant 'runtimeElements' capability root.group.name:A:1.0.0:
- Incompatible because this component declares a library and the consumer needed documentation
- Other compatible attribute:
- Doesn't say anything about the documentation type (required documentation of type 'test-report-data')
- Variant 'sourcesElements' capability root.group.name:A:1.0.0 declares documentation:
- Incompatible because this component declares sources and the consumer needed documentation of type 'test-report-data'
知道为什么这对我来说失败了吗?
解决方案
推荐阅读
- sql - 元组的休眠参数
- reactjs - 如何渲染嵌套在 React Admin 的 show/ArrayField 组件中的对象内的数组的内容?
- shopify - Facebook 像素报告(间歇)“无效的购买价值参数”
- java - 如何使用泛型来简化我的编辑方法
- mysql - 如何排除周末和节假日日期并在 MySQL 中查找预期日期?
- ios - 将绑定结构传递给 SwiftUI 中的视图
- node.js - 如何使用 MERN 将上传的文件与其他文件一起保存?
- php - 带空格的 PHP 电子邮件提取器
- c++ - SetWindowsHookEx 不适用于另一个进程线程 ID 上的 WH_CBT(但适用于自己的线程 ID)
- apache-nifi - QueryDNS 卡住了,如何摆脱 UnexpectedNamingException?