我是 Gradle 的新手,它对我来说仍然有点神奇。
在我的项目中,我们不使用默认的 sourceDirs,因为我们将不同类型的测试分开:
configure(subprojects) {
sourceSets {
test {
java.srcDir('src/test/unit/java')
resources.srcDir('src/test/unit/resources')
}
integrationTest {
java.srcDir('src/test/integration/java')
resources.srcDir('src/test/integration/resources')
}
concurrencyTest {
java.srcDir('src/test/concurrency/java')
resources.srcDir('src/test/concurrency/resources')
}
componentTest {
java.srcDir('src/test/component/java')
resources.srcDir('src/test/component/resources')
}
}
}
我正在尝试配置一个 scala 测试源目录。我的尝试:
apply plugin: 'scala'
configure(subprojects) {
sourceSets {
test {
java.srcDir('src/test/unit/java')
scala.srcDir('src/test/unit/scala')
resources.srcDir('src/test/unit/resources')
}
...
结果:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\projects\...\build.gradle' line: 109
# note, this is the line "sourceSets {"
* What went wrong:
A problem occurred evaluating root project 'X'.
> Could not find method sourceSets() for arguments [build_5ft63n6d7svimaibmkfq56rbrk$_run_closure4_closure18@573ed6c3] on root project 'X'.
我尝试了其他一些变体,但无法使其正常工作。有人可以帮忙吗?