我有一个gradle项目,并具有main和test作为sourceSets。
我确实希望test-main不成为测试源集的一部分。现在我遇到的问题是,在构建项目时,将test-main标记为Sources Root而不是Test Sources Root。
这会导致编译错误,并且我必须手动将测试主体标记为所有子项目的“源测试根”。
我创建了一个任务,以强制将intellij标记为Sources Test Root,但似乎我做错了什么。
提示:
谢谢,
subprojects {
apply plugin: 'java' // all our projects are Java projects
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.warnings = false // There are too many :-(
}
configurations {
testMainsCompile.extendsFrom testCompile
testMainsRuntime.extendsFrom testMainsCompile
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs …
Run Code Online (Sandbox Code Playgroud)