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!

bjoern
  • 1,009
  • 3
  • 15
  • 31

2 Answers2

1

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"
        }
    }
}
Andreas Schmid
  • 1,195
  • 8
  • 13
0

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.

Radim
  • 4,721
  • 1
  • 22
  • 25
  • In eclipse you can easily configure a nested folder within a source folder to be treated as a separate source folder. But I need a way to replicate that in gradle, otherwise right now I cannot launch my tests from within eclipse because it says that my resources are not in the classpath. – bjoern Apr 23 '14 at 14:29
  • Why on Earth do you want to do such a think? You will have to deal with this when you want to build your project with any build tool. You will have to deal with it when you realize there can be another IDE too. If you used 'test/java` + `test/resources` or just one root `test` your life would be much easier. – Radim Apr 23 '14 at 16:35