【发布时间】:2019-04-19 12:37:37
【问题描述】:
我的一个 gradle 子项目的测试源中有一些实用程序文件,我想在其他子项目中使用它们。
我的“源”子项目称为core,而使用它的子项目称为tem。
我尝试迁移和集成following example:
In your Server project:
configurations {
testArtifacts.extendsFrom testCompile
}
task testJar(type: Jar) {
classifier "test"
from sourceSets.test.output
}
artifacts {
testArtifacts testJar
}
In your ServerWeb project:
testCompile project(path: ":Server", configuration: 'testArtifacts')
据我所知,正在进行对话。我在core.gradle.kts 中添加了以下内容:
val testConfig = configurations.create("testArtifacts") {
extendsFrom(configurations["testCompile"])
}
tasks.register("testJar", Jar::class.java) {
classifier += "test"
from(sourceSets["test"].output)
}
artifacts {
add("testArtifacts", tasks.named<Jar>("testJar") )
}
并尝试在tem.gradle.kts中引用它:
testImplementation(project(":core", "testArtifacts"))
它可以编译,但我仍然无法从核心访问这些类。
我错过了什么?
【问题讨论】:
标签: gradle build.gradle gradle-kotlin-dsl