Separate src/main and src/test sourceSets

Continuing the discussion from Wtp-eclipse plugin: wb-resources not generated correctly when using task "eclipse":

Continuing the discussion from Eclipse Plugin improvement suggestions:

Hi Michael,

Could you perhaps share the fix you have applied for point 3? I’m facing a similar situation and that snippet would help.

Thanks!

Here’s what I use for #3:

eclipse.classpath {
    defaultOutputDir = project.file('bin/main')
    
    file.beforeMerged { cp ->
        cp.entries.clear()
        // without this command, modified test classpath entries will be duplicated for some reason.
    }
    file.whenMerged { cp ->
        def testEntries = cp.entries.findAll { it instanceof SourceFolder && it.path.startsWith("src/test/") }
        testEntries*.output = 'bin/test'
    }
}

EDIT: initially got confused by my own numbering and posted the well-known fix for #5, instead of #3. Sorry about that.