Eclipse ignores outputDir

I’m tearing my hair out trying to get the eclipse integration to accept a class output directory separate from “bin/main” in my Java proect, but it completely ignores whatever I tell it. I’ve tried changing the source sets in any way I can think of. I’ve played with the defaultOutputDir of the eclipse task, but it is simply refusing to generate a .classpath with anything except the default dir. And “bin” is used for something else in our project, so it is not possible to use that one…

Why is it flat-out ignoring “outputdir” from below when generating the .classpath for eclipse?

sourceSets {
main {
java {
srcDirs ‘source’
outputDir = file(‘foobar’)

Similarly, if I add the following, it still sets up “bin/main”
eclipse {
defaultOutputDir = file(‘foobar’)

I’ve read the API documentation back and forth on the eclipse tasks as well as the SourceSet-related classes, and I don’t see any way to do this. Isn’t it possible to generate a .classpath with anything except the bin/-prefix?

Note: using gradle-5.0.

Edit: I seem to be able to overwrite the “bin” paths with the code supplied in the answer on this post:
But is that really the only way to change the output directories? It seems quite complicated for such an easy thing.

If you still haven’t found a solution, you can try to manipulate the .classpath file directly.

  • Solution 1
    eclipse { classpath { file { whenMerged {
    def specialSource = entries.find { it.path =“sourceFolder” }
    specialSource .setOutput(“outputRelativePath”)

  • Solution 2
    eclipse { classpath { file { whenMerged {
    def specialSource = new org.gradle.plugins.ide.eclipse.model.SourceFolder(“sourceFolder”,“outputRelativePath”)
    entries += specialSource

(In solution 2 you use the second constructor for a new classpath entry and directly create one (entry) of: kind=“src”, output = “outputRelativePath” and path = “sourceFolder”. Afterwards, you can add any other desired attributes. This worked for me when I was trying to add a certain attribute to an output folder)