我有两个项目,项目 A 和项目 B。它们都是用 groovy 编写的,并使用 gradle 作为构建系统。
项目 A 需要项目 B。 这适用于编译和测试代码。
如何配置项目A的测试类可以访问项目B的测试类?
最佳答案
您可以通过“测试”配置公开测试类,然后在该配置上定义一个 testCompile 依赖项。
我对所有的 java 项目都有这个 block ,它包含所有的测试代码:
task testJar(type: Jar, dependsOn: testClasses) {
baseName = "test-${project.archivesBaseName}"
from sourceSets.test.output
}
configurations {
tests
}
artifacts {
tests testJar
}
然后,当我有测试代码时,我想在我使用的项目之间访问
dependencies {
testCompile project(path: ':aProject', configuration: 'tests')
}
这是针对 Java 的;我假设它也应该适用于 groovy。
https://stackoverflow.com/questions/5144325/