【发布时间】:2019-04-14 09:44:01
【问题描述】:
我在 gradle 中有一个多项目构建。在项目gradle-playground-a 中,我正在创建一个带有一些junit 测试的测试jar:
plugins {
id 'java'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
repositories {
mavenCentral()
}
test.enabled = false
configurations {
testArtifacts.extendsFrom testRuntime
}
task testJar(type: Jar) {
classifier "test"
from sourceSets.test.output
}
artifacts {
testArtifacts testJar
}
现在我想在另一个项目gradle-playground-b 中运行 test-jar 的测试。因此我有:
plugins {
id 'java'
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testRuntimeOnly project (path: ":gradle-playground-a", configuration: 'testArtifacts')
}
repositories {
mavenCentral()
}
但是,来自 test-jar 的测试没有运行。当我查看 gradles 调试输出时,我看到 test-jar 包含在 gradle-playground-b 的测试执行的类路径中。
我想做的是拥有与mavens surefire depednenciesToScan 等效的功能。
在测试gradle-playground-b 时如何从 test-jar 执行测试?
【问题讨论】: