0

I have an app that consists of multiple project. Each has the following layout:

src/

test/

test/resources

Here is part of my gradle.build file with the custom sourceSets.

subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
dependencies {
    testCompile "junit:junit:4.11"
}
sourceSets {
    main {
        java {
            srcDir 'src'
        }
    }
    test {
        java {
            srcDir "test"
        }
        resources {           
          srcDir "resources"
        }
    }
}
}

When I right click on the project in eclipse and "Refresh All" it does not make test/resources a source folder. Only src and test are source folders. Am I not understanding something? Do i have to add the resources to the classpath separately? Any help would be greatly appreciated, thanks!

4

2 回答 2

1

由于“测试/资源”嵌套文件夹的事情,我同意 Radim。无论如何,如果您想在 Eclipse 中将 test/resources 文件夹添加到您的项目中,您必须编写以下内容:

sourceSets {
    main {
        java {
            srcDir 'src'
        }
    }
    test {
        java {
            srcDir "test"
        }
        resources {
          srcDir "test/resources"
        }
    }
}
于 2014-12-13T17:26:30.430 回答
0

您是否检查过 Eclipse 中的错误日志?

sourceSets.test.resources.srcDir现在设置为资源(可能在您的项目中丢失)而不是“测试/资源”。即使那样,我也会担心test/test/resources嵌套是否适用于 Eclipse。您可以尝试使用一些排除来为 Eclipse 定义两个单独的树。

于 2014-04-22T18:18:42.317 回答