bjoern
bjoern

Reputation: 1019

Nested test resources causing buildpath issues using Gradle in Eclipse

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!

Upvotes: 0

Views: 1324

Answers (2)

Andreas Schmid
Andreas Schmid

Reputation: 1215

I agree with Radim due to the "test/resources" nested folder thing. Anyway, if you want to add have the test/resources folder added to your project in Eclipse, you have to write following:

sourceSets {
    main {
        java {
            srcDir 'src'
        }
    }
    test {
        java {
            srcDir "test"
        }
        resources {
          srcDir "test/resources"
        }
    }
}

Upvotes: 1

Radim
Radim

Reputation: 4808

Have you checked error log in your Eclipse?

Your sourceSets.test.resources.srcDir is now set to resources (probably missing in your project) and not 'test/resource'. Even then I'd be afraid if that test / test/resources nesting will work with Eclipse. You can try to use some excludes to define two separate trees for Eclipse.

Upvotes: 0

Related Questions