Impossible to remove main source set when using eclipse plugin?

I would like to create source directories for custom source sets and also use the eclipse plugin. I also would like to not have a ‘main’ source set in my project.

The example can be found here

Now it would be easy if I could just use

sourceSets { remove main }

, but then the eclipse plugin stops working: >* What went wrong: >Could not determine the dependencies of task ‘:eclipseClasspath’. >Could not find property ‘main’ on SourceSet container.

I guess it is because of lines 139, 142 in

I am wondering why this convention is hard coded in this way.

Is there a drawback in always adding all declared java source sets to the classpath? When working with multiple source sets, usually the first thing I do is

eclipse {
    classpath.plusConfigurations += configurations.newConfiguration

I feel like this should be default… Could the problem be with this, that you could actually create a project which shows no errors in Eclipse but cannot compile with Gradle? I.e. if you added all configurations to the eclipse classpath, without declaring possible source set dependencies?

Re main sourceSet: you are right that eclipse (and idea) plugin has some hard-coded depencencies on java plugin. Generally we want to make it better configurable. This should cover cases when java-base plugin is used without java plugin ( I am not sure when this will happen but if you really need it you can consider submitting a patch.

As for the mapping between configurations and Eclipse classpath: Eclipse project has much simpler model for its classpath and it means that the generated classpath is an approximation and there is no universal solutions ( is related to this topic). The default works well for project without special customization and it feels easier and safer to let people add than to ask them to filter inappropriately added content.