我是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'.
我尝试过其他一些变种,但无法让它发挥作用。有人可以帮忙吗?
答案 0 :(得分:1)
sourceSets
扩展名由scala
等语言插件添加,但您未将scala
插件应用于子项目。因此错误。
PS:您可以使用configure(subprojects) { ... }
而不是subprojects { ... }
。